class

PlaceOS::Model::EventMetadata

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

CALLBACKS = { before_save: [:record_metadata_history] of Nil, after_save: [] of Nil, before_create: [do self.created_at = self.updated_at = Time.utc end] of Nil, after_create: [] of Nil, before_update: [do if event_start_changed? || event_end_changed? linked_bookings = self.bookings if linked_bookings.size > 0 clashing = linked_bookings.select do |booking| booking.booking_start = event_start booking.booking_end = event_end booking.clashing? end if clashing.empty? else (Booking.where({:id => clashing.map(&.id)})).update_all({:rejected => true, :rejected_at => Time.utc.to_unix}) end Booking.where(event_id: id).update_all({:booking_start => event_start, :booking_end => event_end}) end end if cancelled_changed? && cancelled Booking.where(event_id: id).update_all({:rejected => true, :rejected_at => Time.utc.to_unix}) end end, do self.updated_at = Time.utc end] of Nil, after_update: [] of Nil, before_destroy: [:destroy_attendees, :destroy_bookings] of Nil, after_destroy: [] of Nil, }
Log = ::Log.for(self)
PRIMARY_KEY_TYPES = {:id => (Int64 | Nil)} of Nil => Nil

macro level key => type

PRIMARY_KEYS = [{:id}]

Constructors

from_json(string_or_io : String | IO, trusted : Bool = false) : self
from_json(string_or_io : String | IO, root : String, trusted : Bool = false) : self

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">
from_trusted_json(string_or_io : String | IO, root : String) : self
from_trusted_json(string_or_io : String | IO) : self

Serialize from a trusted JSON source

from_trusted_yaml(string_or_io : String | IO) : self

Serialize from a trusted YAML source

from_yaml(string_or_io : String | IO, trusted : Bool = false) : self
new(rs : DB::ResultSet)
new(system_id : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, event_id : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, recurring_master_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, ical_uid : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, resource_master_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, host_email : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, resource_calendar : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, event_start : Int64 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, event_end : Int64 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, cancelled : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, ext_data : JSON::Any | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, setup_time : Int64 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, breakdown_time : Int64 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, setup_event_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, breakdown_event_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, permission : PlaceOS::Model::EventMetadata::Permission | ActiveModel::Model::None = ::ActiveModel::Model::None.new, tenant_id : Int64 | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : Int64 | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, created_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new, updated_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new)

Initialize PlaceOS::Model::EventMetadata from HTTP::Params.

Class methods

attributes

Returns all attribute keys.

by_event_ids(event_ids)
Source
by_events_or_master_ids(event_ids, master_ids)
Source
by_ext_data(field_name, value)
Source
by_master_ids(master_ids)
Source
by_tenant(tenant_id)
Source
by_tenant_id(id)

Look up instances of this model dependent on the foreign key

Source
changes(id : Int64 | Nil | Nil = nil) : ChangeFeed

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.

elastic
from_rs(__temp_1840 : DB::ResultSet)
is_ending_after(start_time)
Source
is_starting_before(end_time)
Source
migrate_recurring_metadata(system_id : String, recurrance : PlaceCalendar::Event, parent_metadata : EventMetadata)
Source
on_error(err : Exception | IO::Error)
primary_key

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

Source
table_name

Instance methods

__tenant
__tenant=(__tenant : Tenant | Nil)
after_create

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

after_destroy

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

after_initialize(trusted : Bool)
after_save

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

after_update

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

apply_defaults

Generate code to apply default values

assign_attributes(system_id : String | Missing = Missing, event_id : String | Missing = Missing, recurring_master_id : String | Nil | Missing = Missing, ical_uid : String | Missing = Missing, resource_master_id : String | Nil | Missing = Missing, host_email : String | Missing = Missing, resource_calendar : String | Missing = Missing, event_start : Int64 | Missing = Missing, event_end : Int64 | Missing = Missing, cancelled : Bool | Missing = Missing, ext_data : JSON::Any | Nil | Missing = Missing, setup_time : Int64 | Missing = Missing, breakdown_time : Int64 | Missing = Missing, setup_event_id : String | Nil | Missing = Missing, breakdown_event_id : String | Nil | Missing = Missing, permission : PlaceOS::Model::EventMetadata::Permission | Missing = Missing, tenant_id : Int64 | Nil | Missing = Missing, id : Int64 | Nil | Missing = Missing, created_at : Time | Missing = Missing, updated_at : Time | Missing = Missing)

Assign to multiple attributes.

assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))

Assign to multiple attributes via HTTP::Params.

assign_attributes(model : PlaceOS::Model::EventMetadata)

Assign to multiple attributes from a model object

assign_attributes_from_json(json, root : String)
assign_attributes_from_json(json)
assign_attributes_from_trusted_json(json, root : String)
assign_attributes_from_trusted_json(json)

Assign each field from JSON if field exists in JSON and has changed in model

assign_attributes_from_trusted_yaml(yaml)
assign_attributes_from_yaml(yaml)

Uses the YAML parser as JSON is valid YAML

attendees
Source
attributes

Returns a Hash of all attribute values

attributes_tuple

Returns a NamedTuple of all attribute values.

before_create

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

before_destroy

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

before_save

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

before_update

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

bookings
Source
breakdown_event_id

breakdown_event_id getter

breakdown_event_id=(value : String | Nil)

breakdown_event_id setter

breakdown_event_id_assigned?
breakdown_event_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

breakdown_event_id_changed?
breakdown_event_id_default

breakdown_event_id's default value

Source
breakdown_event_id_present?
breakdown_event_id_removed?
breakdown_event_id_was
breakdown_event_id_will_change!

Include breakdown_event_id in the set of changed attributes, whether it has changed or not.

breakdown_time

breakdown_time getter

breakdown_time=(value : Int64)

breakdown_time setter

breakdown_time?

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.

breakdown_time_assigned?
breakdown_time_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

breakdown_time_changed?
breakdown_time_default

breakdown_time's default value

Source
breakdown_time_present?
breakdown_time_removed?
breakdown_time_was
breakdown_time_will_change!

Include breakdown_time in the set of changed attributes, whether it has changed or not.

cancelled

cancelled getter

cancelled=(value : Bool)

cancelled setter

cancelled?

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.

cancelled_assigned?
cancelled_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

cancelled_changed?
cancelled_default

cancelled's default value

Source
cancelled_present?
cancelled_removed?
cancelled_was
cancelled_will_change!

Include cancelled in the set of changed attributes, whether it has changed or not.

changed?

Check if any attributes have changed.

changed_attributes

Returns a Hash with all changed attributes.

changed_json(io : IO) : Nil

Serialize the set of changed attributes to JSON.

changed_json

Serialize the set of changed attributes to JSON.

changed_persist_attributes
changed_yaml(io : IO) : Nil

Serialize the set of changed attributes to YAML.

changed_yaml

Serialize the set of changed attributes to YAML.

clear_changes_information

Reset changes for all attributes.

created_at

created_at getter

created_at=(value : Time)

created_at setter

created_at?

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.

created_at_assigned?
created_at_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

created_at_changed?
created_at_default

created_at's default value

created_at_present?
created_at_removed?
created_at_was
created_at_will_change!

Include created_at in the set of changed attributes, whether it has changed or not.

destroy_attendees
destroy_bookings
event_end

event_end getter

event_end=(value : Int64)

event_end setter

event_end?

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.

event_end_assigned?
event_end_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

event_end_changed?
event_end_default

event_end's default value

Source
event_end_present?
event_end_removed?
event_end_was
event_end_will_change!

Include event_end in the set of changed attributes, whether it has changed or not.

event_id

event_id getter

event_id=(value : String)

event_id setter

event_id?

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.

event_id_assigned?
event_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

event_id_changed?
event_id_default

event_id's default value

Source
event_id_present?
event_id_removed?
event_id_was
event_id_will_change!

Include event_id in the set of changed attributes, whether it has changed or not.

event_start

event_start getter

event_start=(value : Int64)

event_start setter

event_start?

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.

event_start_assigned?
event_start_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

event_start_changed?
event_start_default

event_start's default value

Source
event_start_present?
event_start_removed?
event_start_was
event_start_will_change!

Include event_start in the set of changed attributes, whether it has changed or not.

ext_data

ext_data getter

ext_data=(value : JSON::Any | Nil)

ext_data setter

ext_data_assigned?
ext_data_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

ext_data_changed?
ext_data_default

ext_data's default value

Source
ext_data_present?
ext_data_removed?
ext_data_was
ext_data_will_change!

Include ext_data in the set of changed attributes, whether it has changed or not.

for_event_instance?(event, client_id)
Source
host_email

host_email getter

host_email=(value : String)

host_email setter

host_email?

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.

host_email_assigned?
host_email_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

host_email_changed?
host_email_default

host_email's default value

Source
host_email_present?
host_email_removed?
host_email_was
host_email_will_change!

Include host_email in the set of changed attributes, whether it has changed or not.

ical_uid

ical_uid getter

ical_uid=(value : String)

ical_uid setter

ical_uid?

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.

ical_uid_assigned?
ical_uid_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

ical_uid_changed?
ical_uid_default

ical_uid's default value

Source
ical_uid_present?
ical_uid_removed?
ical_uid_was
ical_uid_will_change!

Include ical_uid in the set of changed attributes, whether it has changed or not.

id

id getter

id=(value : Int64 | Nil)

id setter

id?
id_assigned?
id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

id_changed?
id_default

id's default value

id_present?
id_removed?
id_was
id_will_change!

Include id in the set of changed attributes, whether it has changed or not.

invoke_props

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

linked_bookings
Source
linked_bookings=(linked_bookings : Array(Booking) | Nil)
Source
permission

permission getter

permission setter

permission?

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.

permission_assigned?
permission_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

permission_changed?
permission_default

permission's default value

Source
permission_present?
permission_removed?
permission_was
permission_will_change!

Include permission in the set of changed attributes, whether it has changed or not.

persistent_attributes

Returns a Hash of all attributes that can be persisted.

primary_key

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

Source
primary_key_hash
recurring_master_id

recurring_master_id getter

recurring_master_id=(value : String | Nil)

recurring_master_id setter

recurring_master_id_assigned?
recurring_master_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

recurring_master_id_changed?
recurring_master_id_default

recurring_master_id's default value

Source
recurring_master_id_present?
recurring_master_id_removed?
recurring_master_id_was
recurring_master_id_will_change!

Include recurring_master_id in the set of changed attributes, whether it has changed or not.

render_linked_bookings=(render_linked_bookings : Bool)
Source
render_linked_bookings?
Source
reset_associations
Source
resource_calendar

resource_calendar getter

resource_calendar=(value : String)

resource_calendar setter

resource_calendar?

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.

resource_calendar_assigned?
resource_calendar_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

resource_calendar_changed?
resource_calendar_default

resource_calendar's default value

Source
resource_calendar_present?
resource_calendar_removed?
resource_calendar_was
resource_calendar_will_change!

Include resource_calendar in the set of changed attributes, whether it has changed or not.

resource_master_id

resource_master_id getter

resource_master_id=(value : String | Nil)

resource_master_id setter

resource_master_id_assigned?
resource_master_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

resource_master_id_changed?
resource_master_id_default

resource_master_id's default value

Source
resource_master_id_present?

this allows us to find the recurring master metadata from the resource calendar annoying how hard this is to find on MS Graph API.

resource_master_id_removed?
resource_master_id_was
resource_master_id_will_change!

Include resource_master_id in the set of changed attributes, whether it has changed or not.

restore_attributes

Reset each attribute to their previous values and clears all changes.

set_ext_data(meta : JSON::Any)
Source
setup_event_id

setup_event_id getter

setup_event_id=(value : String | Nil)

setup_event_id setter

setup_event_id_assigned?
setup_event_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

setup_event_id_changed?
setup_event_id_default

setup_event_id's default value

Source
setup_event_id_present?
setup_event_id_removed?
setup_event_id_was
setup_event_id_will_change!

Include setup_event_id in the set of changed attributes, whether it has changed or not.

setup_time

setup_time getter

setup_time=(value : Int64)

setup_time setter

setup_time?

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.

setup_time_assigned?
setup_time_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

setup_time_changed?
setup_time_default

setup_time's default value

Source
setup_time_present?
setup_time_removed?
setup_time_was
setup_time_will_change!

Include setup_time in the set of changed attributes, whether it has changed or not.

system_id

system_id getter

system_id=(value : String)

Setters system_id setter

system_id?

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.

system_id_assigned?
system_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

system_id_changed?
system_id_default

system_id's default value

Source
system_id_present?
system_id_removed?
system_id_was
system_id_will_change!

Include system_id in the set of changed attributes, whether it has changed or not.

table_name
tenant

Retrieves the parent relationship

Source
tenant!
Source
tenant=(parent : Tenant)

Sets the parent relationship

Source
tenant_id

tenant_id getter

tenant_id=(value : Int64 | Nil)

tenant_id setter

tenant_id_assigned?
tenant_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

tenant_id_changed?
tenant_id_default

tenant_id's default value

tenant_id_present?
tenant_id_removed?
tenant_id_was
tenant_id_will_change!

Include tenant_id in the set of changed attributes, whether it has changed or not.

to_json(json : JSON::Builder)
Source
updated_at

updated_at getter

updated_at=(value : Time)

updated_at setter

updated_at?

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.

updated_at_assigned?
updated_at_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

updated_at_changed?
updated_at_default

updated_at's default value

updated_at_present?
updated_at_removed?
updated_at_was
updated_at_will_change!

Include updated_at in the set of changed attributes, whether it has changed or not.

validate_nilability

Validate that all non-nillable fields have values.

Macros

scope(name, &block)

Nested types