Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
PlaceOS::Model::BookingInstance
Inherits PlaceOS::Model::Timestamps < PlaceOS::Model::Scope < PlaceOS::Model::Associations < PlaceOS::Model::ModelWithAutoKey < Neuroplastic < PgORM::Base < PgORM::Validators < PgORM::Table < PgORM::Persistence < PgORM::Associations < ActiveModel::Callbacks < ActiveModel::Validation < ActiveModel::Model < DB::Mappable < DB::Serializable < YAML::Serializable < JSON::Serializable < Reference < Object
Constants
macro level key => type
Constructors
Deserializes the given JSON in string_or_io into
an instance of self, assuming the JSON consists
of an JSON object with key root, and whose value is
the value to deserialize. Will not deserialise from
fields with mass_assign: false
class User < ActiveModel::Model
attribute name : String
attribute google_id : UUID, mass_assign: false
end
User.from_json(%({"main": {"name": "Jason", "google_id": "f6f70bfb-c882-446d-8758-7ce47db39620"}}), root: "main") # => #<User:0x103131b20 @name="Jason">
Class methods
Returns all attribute keys.
Changefeed at row (if id passed) or whole table level.
Returns a ChangeFeed instance which can be used to invoke async callbacks via on or
use blocking Iterator via each method.
Instance methods
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Generate code to apply default values
approved getter
approved setter
approved_at getter
approved_at setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include approved_at in the set of changed attributes, whether it has changed or not.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
custom approval state, nil fields inherit from the parent booking. if either approved or rejected is set, all the approval fields are considered overridden as a group (see #hydrate_booking)
Include approved in the set of changed attributes, whether it has changed or not.
approver_email getter
approver_email setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include approver_email in the set of changed attributes, whether it has changed or not.
approver_id getter
approver_id setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include approver_id in the set of changed attributes, whether it has changed or not.
approver_name getter
approver_name setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include approver_name in the set of changed attributes, whether it has changed or not.
asset_id getter
asset_id setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
custom asset allocation, nil inherits the parent booking assets
Include asset_id in the set of changed attributes, whether it has changed or not.
asset_ids getter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include asset_ids in the set of changed attributes, whether it has changed or not.
Assign to multiple attributes.
Assign to multiple attributes via HTTP::Params.
Assign to multiple attributes from a model object
Assign each field from JSON if field exists in JSON and has changed in model
Uses the YAML parser as JSON is valid YAML
Returns a Hash of all attribute values
Returns a NamedTuple of all attribute values.
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
booking_end getter
booking_end setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include booking_end in the set of changed attributes, whether it has changed or not.
booking_start getter
booking_start setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
the new start and end times
Include booking_start in the set of changed attributes, whether it has changed or not.
Check if any attributes have changed.
Returns a Hash with all changed attributes.
Serialize the set of changed attributes to JSON.
Serialize the set of changed attributes to JSON.
Serialize the set of changed attributes to YAML.
Serialize the set of changed attributes to YAML.
checked_in getter
checked_in setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
checked_in_at getter
checked_in_at setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include checked_in_at in the set of changed attributes, whether it has changed or not.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include checked_in in the set of changed attributes, whether it has changed or not.
checked_out_at getter
checked_out_at setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include checked_out_at in the set of changed attributes, whether it has changed or not.
Reset changes for all attributes.
created_at getter
created_at setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
created_at's default value
Include created_at in the set of changed attributes, whether it has changed or not.
An occurrence keeps its own history: Booking#save! delegates to
as_instance.save!, so the parent's before_save (and the current_history
it builds) never runs for an instance. Without this the occurrence records no
transitions at all and the utm_source behind them is lost.
Mirrors Booking#current_history. State comes from the hydrated booking --
that is exactly what the API presents for this occurrence, so its state is the
one the history should record, and it avoids duplicating the state machine.
deleted getter
deleted setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
deleted_at getter
deleted_at setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include deleted_at in the set of changed attributes, whether it has changed or not.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include deleted in the set of changed attributes, whether it has changed or not.
extension_data getter
extension_data setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include extension_data in the set of changed attributes, whether it has changed or not.
history getter
history setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include history in the set of changed attributes, whether it has changed or not.
returns a booking object that represents this instance
id getter
id setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
id's default value
Include id in the set of changed attributes, whether it has changed or not.
instance_start getter
Setters
instance_start setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
the original starting time of the instance
Include instance_start in the set of changed attributes, whether it has changed or not.
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
property so we can set this if we've already fetched the parent
Returns a Hash of all attributes that can be persisted.
Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk
process_state getter
process_state setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include process_state in the set of changed attributes, whether it has changed or not.
rejected getter
rejected setter
rejected_at getter
rejected_at setter
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include rejected_at in the set of changed attributes, whether it has changed or not.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include rejected in the set of changed attributes, whether it has changed or not.
Reset each attribute to their previous values and clears all changes.
transient flag (never (de)serialised, so API clients cannot set it): set by
Booking#as_instance when the caller has already run an explicit clash
check, so save! does not redundantly re-run it.
transient flag (never (de)serialised, so API clients cannot set it): set by
Booking#as_instance when the caller has already run an explicit clash
check, so save! does not redundantly re-run it.
the clash validation only needs to run when the booked slot itself (time or asset) changes. approving, rejecting or checking in an existing instance must not be blocked by a clash it did not introduce.
tenant_id getter
tenant_id setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include tenant_id in the set of changed attributes, whether it has changed or not.
keep the custom asset_id and asset_ids in sync, mirroring Booking#update_assets but with nil meaning inherit from the parent
updated_at getter
updated_at setter
NOTE: use getter / getter! (not property / property!) so that the
setter defined later in __create_initializer__ is the only setter on
the field. Crystal's overload resolution silently fails to replace a
property-defined setter with one of identical signature for generic
types (e.g. Set(String)?, Array(String)?, String | Array(String)),
although it does work for non-generic ones like String?. Defining the
setter only once via __create_initializer__ ensures change tracking,
sanitization, and custom setter blocks run uniformly across all types.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
updated_at's default value
Include updated_at in the set of changed attributes, whether it has changed or not.
Accessors for attributes without JSON mapping
utm_source setter
Accessors for attributes without JSON mapping
Returns a Tuple of the previous and the current value of an instance variable if it has changed
transient, mirrors Booking#utm_source -- recorded against the history entry
of the transition it caused, never persisted as a column of its own
Include utm_source in the set of changed attributes, whether it has changed or not.
Validate that all non-nillable fields have values.