class PlaceOS::Model::TriggerInstance
- PlaceOS::Model::TriggerInstance
- PlaceOS::Model::ModelBase
- PgORM::Base
- ActiveModel::Model
- Reference
- Object
Included Modules
Defined in:
placeos-models/trigger_instance.crConstant Summary
-
CALLBACKS =
{before_save: [:check_playlists] of Nil, after_save: [] of Nil, before_create: [do self.created_at = self.updated_at = Time.utc end, :set_importance] of Nil, after_create: [] of Nil, before_update: [do self.updated_at = Time.utc end] of Nil, after_update: [] of Nil, before_destroy: [] of Nil, after_destroy: [] of Nil}
-
Log =
::Log.for(self)
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. - .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(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(pull : JSON::PullParser)
- .new(rs : DB::ResultSet)
- .new(created_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new, updated_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new, enabled : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, triggered : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, important : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, exec_enabled : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, playlists : Array(String) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, webhook_secret : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, trigger_count : Int32 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, control_system_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, trigger_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, zone_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new)
-
.new(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
Initialize PlaceOS::Model::TriggerInstance from
HTTP::Params
.
Class Method Summary
-
.attributes : Array(Symbol)
Returns all attribute keys.
- .auto_generate_id : Bool
-
.by_control_system_id(id)
Look up instances of this model dependent on the foreign key
-
.by_trigger_id(id)
Look up instances of this model dependent on the foreign key
-
.by_zone_id(id)
Look up instances of this model dependent on the foreign key
-
.changes(id : PrimaryKeyType = nil) : ChangeFeed
Changefeed at row (if
#id
passed) or whole table level. - .elastic
-
.for(control_system_id)
Look up
TriggerInstance
s byControlSystem
- .from_rs(__temp_1032 : DB::ResultSet)
-
.increment_trigger_count(id : String)
Increment the
#trigger_count
of aTriggerInstance
in place. -
.of(trigger_id)
Look up
TriggerInstance
s belonging toTrigger
- .on_error(err : Exception | IO::Error)
- .primary_key : Symbol
- .table_name
Instance Method Summary
- #__control_system : ControlSystem | Nil
- #__control_system=(__control_system : ControlSystem | Nil)
- #__trigger : Trigger | Nil
- #__trigger=(__trigger : Trigger | Nil)
- #__zone : Zone | Nil
- #__zone=(__zone : Zone | Nil)
-
#actions
Proxies the parent
Trigger
's actions attribute. -
#after_create
Base class for all Engine models
-
#after_destroy
Base class for all Engine models
- #after_initialize(trusted : Bool)
-
#after_save
Base class for all Engine models
-
#after_update
Base class for all Engine models
-
#apply_defaults
Generate code to apply default values
-
#as_json
Override to_json, set method fields
DEPRECATED Use
#to_metadata_json
instead. -
#assign_attributes(created_at : Time | Missing = Missing, updated_at : Time | Missing = Missing, enabled : Bool | Missing = Missing, triggered : Bool | Missing = Missing, important : Bool | Missing = Missing, exec_enabled : Bool | Missing = Missing, playlists : Array(String) | Missing = Missing, webhook_secret : String | Missing = Missing, trigger_count : Int32 | Missing = Missing, control_system_id : String | Nil | Missing = Missing, trigger_id : String | Nil | Missing = Missing, zone_id : String | Nil | Missing = Missing, id : String | Nil | Missing = Missing)
Assign to multiple attributes.
-
#assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
Assign to mulitple attributes via
HTTP::Params
. -
#assign_attributes(model : PlaceOS::Model::TriggerInstance)
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
-
#attributes
Returns a
Hash
of all attribute values -
#attributes_tuple
Returns a
NamedTuple
of all attribute values. -
#before_create
Base class for all Engine models
-
#before_destroy
Base class for all Engine models
-
#before_save
Base class for all Engine models
-
#before_update
Base class for all Engine models
-
#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 : String
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 : String
Serialize the set of changed attributes to YAML.
-
#clear_changes_information
Reset changes for all attributes.
-
#conditions
Proxies the parent
Trigger
's conditions attribute. -
#control_system : ControlSystem | Nil
Retrieves the parent relationship
- #control_system! : ControlSystem
-
#control_system=(parent : ControlSystem)
Sets the parent relationship
-
#control_system_id : String | Nil
#control_system_id
getter -
#control_system_id=(value : String | Nil)
#control_system_id
setter - #control_system_id_assigned? : Bool
-
#control_system_id_change : Tuple(String | Nil | Nil, String | Nil | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #control_system_id_changed? : Bool
-
#control_system_id_default : String | Nil
#control_system_id
's default value - #control_system_id_present? : Bool
- #control_system_id_was : String | Nil | Nil
-
#control_system_id_will_change! : Nil
Include
#control_system_id
in the set of changed attributes, whether it has changed or not. -
#created_at : Time
#created_at
getter -
#created_at=(value : Time)
Setters
#created_at
setter - #created_at? : Time | Nil
- #created_at_assigned? : Bool
-
#created_at_change : Tuple(Time | Nil, Time | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #created_at_changed? : Bool
-
#created_at_default : Time
#created_at
's default value - #created_at_present? : Bool
- #created_at_was : Time | Nil
-
#created_at_will_change! : Nil
Include
#created_at
in the set of changed attributes, whether it has changed or not. -
#debounce_period
Proxies the parent
Trigger
's debounce_period attribute. -
#description
Proxies the parent
Trigger
's description attribute. -
#enabled : Bool
#enabled
getter -
#enabled=(value : Bool)
#enabled
setter - #enabled? : Bool | Nil
- #enabled_assigned? : Bool
-
#enabled_change : Tuple(Bool | Nil, Bool | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #enabled_changed? : Bool
-
#enabled_default : Bool
#enabled
's default value - #enabled_present? : Bool
- #enabled_was : Bool | Nil
-
#enabled_will_change! : Nil
Include
#enabled
in the set of changed attributes, whether it has changed or not. -
#exec_enabled : Bool
#exec_enabled
getter -
#exec_enabled=(value : Bool)
#exec_enabled
setter - #exec_enabled? : Bool | Nil
- #exec_enabled_assigned? : Bool
-
#exec_enabled_change : Tuple(Bool | Nil, Bool | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #exec_enabled_changed? : Bool
-
#exec_enabled_default : Bool
#exec_enabled
's default value - #exec_enabled_present? : Bool
- #exec_enabled_was : Bool | Nil
-
#exec_enabled_will_change! : Nil
Include
#exec_enabled
in the set of changed attributes, whether it has changed or not. -
#id : String | Nil
#id
getter -
#id=(value : String | Nil)
#id
setter -
#id? : String | Nil | Nil
Same as
#id
but may returnnil
when the record hasn't been saved instead of raising. - #id_assigned? : Bool
-
#id_change : Tuple(String | Nil | Nil, String | Nil | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #id_changed? : Bool
-
#id_default : String | Nil
#id
's default value - #id_present? : Bool
- #id_was : String | Nil | Nil
-
#id_will_change! : Nil
Include
#id
in the set of changed attributes, whether it has changed or not. -
#important : Bool
#important
getter -
#important=(value : Bool)
#important
setter - #important? : Bool | Nil
- #important_assigned? : Bool
-
#important_change : Tuple(Bool | Nil, Bool | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #important_changed? : Bool
-
#important_default : Bool
#important
's default value - #important_present? : Bool
- #important_was : Bool | Nil
-
#important_will_change! : Nil
Include
#important
in the set of changed attributes, whether it has changed or not. -
#invoke_props
Base class for all Engine models
-
#name
Proxies the parent
Trigger
's name attribute. -
#persistent_attributes
Returns a
Hash
of all attributes that can be persisted. -
#playlists : Array(String)
#playlists
getter -
#playlists=(value : Array(String))
#playlists
setter - #playlists? : Array(String) | Nil
- #playlists_assigned? : Bool
-
#playlists_change : Tuple(Array(String) | Nil, Array(String) | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #playlists_changed? : Bool
-
#playlists_default : Array(String)
#playlists
's default value - #playlists_present? : Bool
- #playlists_was : Array(String) | Nil
-
#playlists_will_change! : Nil
Include
#playlists
in the set of changed attributes, whether it has changed or not. - #reset_associations
-
#restore_attributes
Reset each attribute to their previous values and clears all changes.
-
#run_create_callbacks(&)
Wrap a block with callbacks for the appropriate crud operation
-
#run_destroy_callbacks(&)
Base class for all Engine models
-
#run_save_callbacks(&)
Base class for all Engine models
-
#run_update_callbacks(&)
Base class for all Engine models
-
#start
Enables the trigger
-
#stop
Disables the trigger
- #table_name
-
#to_metadata_json(json : JSON::Builder)
Serialize attributes with
:metadata
in itsserialization_group
option -
#to_metadata_json(io : IO) : Nil
Serialize attributes with
:metadata
in itsserialization_group
option -
#to_metadata_json : String
Serialize attributes with
:metadata
in itsserialization_group
option - #to_metadata_struct
-
#trigger : Trigger | Nil
Retrieves the parent relationship
- #trigger! : Trigger
-
#trigger=(parent : Trigger)
Sets the parent relationship
-
#trigger_count : Int32
#trigger_count
getter -
#trigger_count=(value : Int32)
#trigger_count
setter - #trigger_count? : Int32 | Nil
- #trigger_count_assigned? : Bool
-
#trigger_count_change : Tuple(Int32 | Nil, Int32 | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #trigger_count_changed? : Bool
-
#trigger_count_default : Int32
#trigger_count
's default value - #trigger_count_present? : Bool
- #trigger_count_was : Int32 | Nil
-
#trigger_count_will_change! : Nil
Include
#trigger_count
in the set of changed attributes, whether it has changed or not. -
#trigger_id : String | Nil
#trigger_id
getter -
#trigger_id=(value : String | Nil)
#trigger_id
setter - #trigger_id_assigned? : Bool
-
#trigger_id_change : Tuple(String | Nil | Nil, String | Nil | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #trigger_id_changed? : Bool
-
#trigger_id_default : String | Nil
#trigger_id
's default value - #trigger_id_present? : Bool
- #trigger_id_was : String | Nil | Nil
-
#trigger_id_will_change! : Nil
Include
#trigger_id
in the set of changed attributes, whether it has changed or not. -
#triggered : Bool
#triggered
getter -
#triggered=(value : Bool)
#triggered
setter - #triggered? : Bool | Nil
- #triggered_assigned? : Bool
-
#triggered_change : Tuple(Bool | Nil, Bool | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #triggered_changed? : Bool
-
#triggered_default : Bool
#triggered
's default value - #triggered_present? : Bool
- #triggered_was : Bool | Nil
-
#triggered_will_change! : Nil
Include
#triggered
in the set of changed attributes, whether it has changed or not. -
#updated_at : Time
#updated_at
getter -
#updated_at=(value : Time)
#updated_at
setter - #updated_at? : Time | Nil
- #updated_at_assigned? : Bool
-
#updated_at_change : Tuple(Time | Nil, Time | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #updated_at_changed? : Bool
-
#updated_at_default : Time
#updated_at
's default value - #updated_at_present? : Bool
- #updated_at_was : Time | Nil
-
#updated_at_will_change! : Nil
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.
-
#webhook_secret : String
#webhook_secret
getter -
#webhook_secret=(value : String)
#webhook_secret
setter - #webhook_secret? : String | Nil
- #webhook_secret_assigned? : Bool
-
#webhook_secret_change : Tuple(String | Nil, String | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #webhook_secret_changed? : Bool
-
#webhook_secret_default : String
#webhook_secret
's default value - #webhook_secret_present? : Bool
- #webhook_secret_was : String | Nil
-
#webhook_secret_will_change! : Nil
Include
#webhook_secret
in the set of changed attributes, whether it has changed or not. -
#zone : Zone | Nil
Retrieves the parent relationship
- #zone! : Zone
-
#zone=(parent : Zone)
Sets the parent relationship
-
#zone_id : String | Nil
#zone_id
getter -
#zone_id=(value : String | Nil)
#zone_id
setter - #zone_id_assigned? : Bool
-
#zone_id_change : Tuple(String | Nil | Nil, String | Nil | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #zone_id_changed? : Bool
-
#zone_id_default : String | Nil
#zone_id
's default value - #zone_id_present? : Bool
- #zone_id_was : String | Nil | Nil
-
#zone_id_will_change! : Nil
Include
#zone_id
in the set of changed attributes, whether it has changed or not.
Instance methods inherited from module PlaceOS::Model::Playlist::Checker
check_playlists
check_playlists
Instance methods inherited from class PlaceOS::Model::ModelBase
after_create
after_create,
after_destroy
after_destroy,
after_save
after_save,
after_update
after_update,
apply_defaults
apply_defaults,
assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))assign_attributes(model : PlaceOS::Model::ModelBase)
assign_attributes assign_attributes, attributes attributes, attributes_tuple attributes_tuple, before_create before_create, before_destroy before_destroy, before_save before_save, before_update before_update, invoke_props invoke_props, persistent_attributes persistent_attributes, run_create_callbacks(&) run_create_callbacks, run_destroy_callbacks(&) run_destroy_callbacks, run_save_callbacks(&) run_save_callbacks, run_update_callbacks(&) run_update_callbacks
Constructor methods inherited from class PlaceOS::Model::ModelBase
new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)new(pull : JSON::PullParser)
new(rs : DB::ResultSet) new
Class methods inherited from class PlaceOS::Model::ModelBase
attributes : Array(Symbol)
attributes,
auto_generate_id : Bool
auto_generate_id,
from_rs(rs : DB::ResultSet)
from_rs,
primary_key : Symbol
primary_key
Instance methods inherited from module PlaceOS::Model::Associations
format_list_for_postgres(list : Enumerable(String)) : String
format_list_for_postgres,
reset_associations
reset_associations
Class methods inherited from module PlaceOS::Model::Associations
format_list_for_postgres(list : Enumerable(String)) : String
format_list_for_postgres
Macros inherited from module PlaceOS::Model::Associations
belongs_to(parent_class, dependent = :none, association_name = nil, foreign_key = nil, presence = false, pk_type = nil, serialize = true)
belongs_to,
has_many(child_class, collection_name = nil, dependent = :none, foreign_key = nil, serialize = false)
has_many,
has_one(child_class, dependent = :none, association_name = nil, presence = false)
has_one
Constructor Detail
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">
Serialize from a trusted JSON source
Serialize from a trusted YAML source
Initialize PlaceOS::Model::TriggerInstance from HTTP::Params
.
Class Method Detail
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.
Increment the #trigger_count
of a TriggerInstance
in place.
Instance Method Detail
Base class for all Engine models
Base class for all Engine models
Base class for all Engine models
Base class for all Engine models
Assign to multiple attributes.
Assign to mulitple 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
Base class for all Engine models
Base class for all Engine models
Base class for all Engine models
Base class for all Engine models
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #control_system_id
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 #created_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 #enabled
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 #exec_enabled
in the set of changed attributes, whether it has changed or not.
Same as #id
but may return nil
when the record hasn't been saved
instead of raising.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #id
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 #important
in the set of changed attributes, whether it has changed or not.
Base class for all Engine models
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #playlists
in the set of changed attributes, whether it has changed or not.
Base class for all Engine models
Base class for all Engine models
Base class for all Engine models
Serialize attributes with :metadata
in its serialization_group
option
Serialize attributes with :metadata
in its serialization_group
option
Serialize attributes with :metadata
in its serialization_group
option
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #trigger_count
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 #trigger_id
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 #triggered
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 #updated_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 #webhook_secret
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