class PlaceOS::Model::Trigger::Conditions::TimeDependent

Defined in:

placeos-models/trigger/conditions.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class PlaceOS::Model::SubModel

apply_defaults apply_defaults, assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
assign_attributes(model : PlaceOS::Model::SubModel)
assign_attributes
assign_attributes
, attributes attributes, attributes_tuple attributes_tuple, persistent_attributes persistent_attributes, to_reql to_reql

Constructor methods inherited from class PlaceOS::Model::SubModel

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
new(pull : JSON::PullParser)
new(rs : DB::ResultSet)
new

Class methods inherited from class PlaceOS::Model::SubModel

attributes : Array(Symbol) attributes, from_rs(rs : DB::ResultSet) from_rs

Constructor Detail

def self.from_json(string_or_io : String | IO, trusted : Bool = false) : self #

def 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">

def self.from_trusted_json(string_or_io : String | IO, root : String) : self #

def self.from_trusted_json(string_or_io : String | IO) : self #

Serialize from a trusted JSON source


def self.from_trusted_yaml(string_or_io : String | IO) : self #

Serialize from a trusted YAML source


def self.from_yaml(string_or_io : String | IO, trusted : Bool = false) : self #

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

def self.new(pull : JSON::PullParser) #

def self.new(rs : DB::ResultSet) #

def self.new(type : PlaceOS::Model::Trigger::Conditions::TimeDependent::Type | ActiveModel::Model::None = ::ActiveModel::Model::None.new, time : Time | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, cron : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, timezone : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new) #

def self.new(params : HTTP::Params | Hash(String, String) | Tuple(String, String)) #

Initialize PlaceOS::Model::Trigger::Conditions::TimeDependent from HTTP::Params.


Class Method Detail

def self.attributes : Array(Symbol) #

Returns all attribute keys.


def self.from_rs(rs : DB::ResultSet) #

Instance Method Detail

def after_initialize(trusted : Bool) #

def apply_defaults #

Generate code to apply default values


def assign_attributes(type : PlaceOS::Model::Trigger::Conditions::TimeDependent::Type | Missing = Missing, time : Time | Nil | Missing = Missing, cron : String | Nil | Missing = Missing, timezone : String | Nil | Missing = Missing) #

Assign to multiple attributes.


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

Assign to mulitple attributes via HTTP::Params.


def assign_attributes(model : PlaceOS::Model::Trigger::Conditions::TimeDependent) #

Assign to multiple attributes from a model object


def assign_attributes_from_json(json, root : String) #

def assign_attributes_from_json(json) #

def assign_attributes_from_trusted_json(json, root : String) #

def assign_attributes_from_trusted_json(json) #

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


def assign_attributes_from_trusted_yaml(yaml) #

def assign_attributes_from_yaml(yaml) #

Uses the YAML parser as JSON is valid YAML


def attributes #

Returns a Hash of all attribute values


def attributes_tuple #

Returns a NamedTuple of all attribute values.


def changed? #

Check if any attributes have changed.


def changed_attributes #

Returns a Hash with all changed attributes.


def changed_json(io : IO) : Nil #

Serialize the set of changed attributes to JSON.


def changed_json : String #

Serialize the set of changed attributes to JSON.


def changed_yaml(io : IO) : Nil #

Serialize the set of changed attributes to YAML.


def changed_yaml : String #

Serialize the set of changed attributes to YAML.


def clear_changes_information #

Reset changes for all attributes.


def cron : String | Nil #

#cron getter


def cron=(value : String | Nil) #

#cron setter


def cron_assigned? : Bool #

def cron_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


def cron_changed? : Bool #

def cron_default : String | Nil #

#cron's default value


def cron_present? : Bool #

def cron_was : String | Nil | Nil #

def cron_will_change! : Nil #

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


def persistent_attributes #

Returns a Hash of all attributes that can be persisted.


def restore_attributes #

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


def time : Time | Nil #

#time getter


def time=(value : Time | Nil) #

#time setter


def time_assigned? : Bool #

def time_change : Tuple(Time | Nil | Nil, Time | Nil | Nil) | Nil #

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


def time_changed? : Bool #

def time_default : Time | Nil #

#time's default value


def time_present? : Bool #

def time_was : Time | Nil | Nil #

def time_will_change! : Nil #

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


def timezone : String | Nil #

#timezone getter


def timezone=(value : String | Nil) #

#timezone setter


def timezone_assigned? : Bool #

def timezone_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


def timezone_changed? : Bool #

def timezone_default : String | Nil #

#timezone's default value


def timezone_present? : Bool #

def timezone_was : String | Nil | Nil #

def timezone_will_change! : Nil #

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


#type getter


Setters #type setter



def type_assigned? : Bool #

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


def type_changed? : Bool #

def type_default : Type #

#type's default value


def type_present? : Bool #


def type_will_change! : Nil #

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


def validate_nilability #

Validate that all non-nillable fields have values.