class

PlaceOS::Model::Trigger::Conditions::Comparison

Inherits PlaceOS::Model::SubModel < ActiveModel::Validation < ActiveModel::Model < DB::Mappable < DB::Serializable < YAML::Serializable < JSON::Serializable < Reference < Object

Constants

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. 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)
Source
new(left : Bool | Float64 | Int64 | PlaceOS::Model::Trigger::Conditions::Comparison::StatusVariable | String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, operator : PlaceOS::Model::Trigger::Conditions::Comparison::Operator | ActiveModel::Model::None = ::ActiveModel::Model::None.new, right : Bool | Float64 | Int64 | PlaceOS::Model::Trigger::Conditions::Comparison::StatusVariable | String | ActiveModel::Model::None = ::ActiveModel::Model::None.new)

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

Class methods

attributes

Returns all attribute keys.

from_rs(rs : DB::ResultSet)
Source

Instance methods

after_initialize(trusted : Bool)
apply_defaults

Generate code to apply default values

Assign to multiple attributes.

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

Assign to multiple attributes via HTTP::Params.

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.

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_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.

left

left getter

left?

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.

left_assigned?
left_change

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

left_changed?
left_default

left's default value

Source
left_present?
left_removed?
left_was
left_will_change!

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

operator

operator getter

operator?

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.

operator_assigned?
operator_change

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

operator_changed?
operator_default

operator's default value

Source
operator_present?
operator_removed?
operator_was
operator_will_change!

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

persistent_attributes

Returns a Hash of all attributes that can be persisted.

restore_attributes

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

right

right getter

right?

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.

right_assigned?
right_change

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

right_changed?
right_default

right's default value

Source
right_present?
right_removed?
right_was
right_will_change!

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

validate_nilability

Validate that all non-nillable fields have values.

Nested types