class PlaceOS::Model::Broker
- PlaceOS::Model::Broker
- PlaceOS::Model::ModelBase
- PgORM::Base
- ActiveModel::Model
- Reference
- Object
Included Modules
- OpenAPI::Generator::Serializable::Adapters::ActiveModel
- PlaceOS::Model::Timestamps
Extended Modules
- OpenAPI::Generator::Serializable
Defined in:
placeos-models/broker.crConstant Summary
-
CALLBACKS =
{before_save: [] 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 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, auth_type : PlaceOS::Model::Broker::AuthType | ActiveModel::Model::None = ::ActiveModel::Model::None.new, name : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, description : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, host : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, port : Int32 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, tls : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, username : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, password : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, certificate : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, secret : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, filters : Array(String) | 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::Broker from
HTTP::Params
.
Class Method Summary
-
.attributes : Array(Symbol)
Returns all attribute keys.
- .auto_generate_id : Bool
-
.changes(id : PrimaryKeyType = nil) : ChangeFeed
Changefeed at row (if
#id
passed) or whole table level. - .elastic
- .from_rs(__temp_822 : DB::ResultSet)
- .on_error(err : Exception | IO::Error)
- .primary_key : Symbol
- .table_name
-
.validate_filters(broker : Broker)
Validate broker's
filter
regexes
Instance Method Summary
-
#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
-
#assign_attributes(created_at : Time | Missing = Missing, updated_at : Time | Missing = Missing, auth_type : PlaceOS::Model::Broker::AuthType | Missing = Missing, name : String | Missing = Missing, description : String | Missing = Missing, host : String | Missing = Missing, port : Int32 | Missing = Missing, tls : Bool | Missing = Missing, username : String | Nil | Missing = Missing, password : String | Nil | Missing = Missing, certificate : String | Nil | Missing = Missing, secret : String | Missing = Missing, filters : Array(String) | 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::Broker)
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. -
#auth_type : PlaceOS::Model::Broker::AuthType
#auth_type
getter -
#auth_type=(value : PlaceOS::Model::Broker::AuthType)
#auth_type
setter - #auth_type? : PlaceOS::Model::Broker::AuthType | Nil
- #auth_type_assigned? : Bool
-
#auth_type_change : Tuple(PlaceOS::Model::Broker::AuthType | Nil, PlaceOS::Model::Broker::AuthType | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #auth_type_changed? : Bool
-
#auth_type_default : AuthType
#auth_type
's default value - #auth_type_present? : Bool
- #auth_type_was : PlaceOS::Model::Broker::AuthType | Nil
-
#auth_type_will_change! : Nil
Include
#auth_type
in the set of changed attributes, whether it has changed or not. -
#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
-
#certificate : String | Nil
#certificate
getter -
#certificate=(value : String | Nil)
#certificate
setter - #certificate_assigned? : Bool
-
#certificate_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
- #certificate_changed? : Bool
-
#certificate_default : String | Nil
#certificate
's default value - #certificate_present? : Bool
- #certificate_was : String | Nil | Nil
-
#certificate_will_change! : Nil
Include
#certificate
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 : 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.
-
#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. -
#description : String
#description
getter -
#description=(value : String)
#description
setter - #description? : String | Nil
- #description_assigned? : Bool
-
#description_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
- #description_changed? : Bool
-
#description_default : String
#description
's default value - #description_present? : Bool
- #description_was : String | Nil
-
#description_will_change! : Nil
Include
#description
in the set of changed attributes, whether it has changed or not. -
#filters : Array(String)
#filters
getter -
#filters=(value : Array(String))
#filters
setter -
#filters? : Array(String) | Nil
Regex filters for sensitive data.
- #filters_assigned? : Bool
-
#filters_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
- #filters_changed? : Bool
-
#filters_default : Array(String)
#filters
's default value -
#filters_present? : Bool
Regex filters for sensitive data.
- #filters_was : Array(String) | Nil
-
#filters_will_change! : Nil
Include
#filters
in the set of changed attributes, whether it has changed or not. -
#host : String
#host
getter -
#host=(value : String)
#host
setter - #host? : String | Nil
- #host_assigned? : Bool
-
#host_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
- #host_changed? : Bool
-
#host_default : String
#host
's default value - #host_present? : Bool
- #host_was : String | Nil
-
#host_will_change! : Nil
Include
#host
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. -
#invoke_props
Base class for all Engine models
-
#name : String
#name
getter -
#name=(value : String)
#name
setter - #name? : String | Nil
- #name_assigned? : Bool
-
#name_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
- #name_changed? : Bool
-
#name_default : String
#name
's default value - #name_present? : Bool
- #name_was : String | Nil
-
#name_will_change! : Nil
Include
#name
in the set of changed attributes, whether it has changed or not. -
#password : String | Nil
#password
getter -
#password=(value : String | Nil)
#password
setter - #password_assigned? : Bool
-
#password_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
- #password_changed? : Bool
-
#password_default : String | Nil
#password
's default value - #password_present? : Bool
- #password_was : String | Nil | Nil
-
#password_will_change! : Nil
Include
#password
in the set of changed attributes, whether it has changed or not. -
#persistent_attributes
Returns a
Hash
of all attributes that can be persisted. -
#port : Int32
#port
getter -
#port=(value : Int32)
#port
setter - #port? : Int32 | Nil
- #port_assigned? : Bool
-
#port_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
- #port_changed? : Bool
-
#port_default : Int32
#port
's default value - #port_present? : Bool
- #port_was : Int32 | Nil
-
#port_will_change! : Nil
Include
#port
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.
-
#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
-
#sanitize(payload : String)
Hash sensitive data from a string using the document's
#filters
-
#secret : String
#secret
getter -
#secret=(value : String)
#secret
setter - #secret? : String | Nil
- #secret_assigned? : Bool
-
#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
- #secret_changed? : Bool
-
#secret_default : String
#secret
's default value - #secret_present? : Bool
- #secret_was : String | Nil
-
#secret_will_change! : Nil
Include
#secret
in the set of changed attributes, whether it has changed or not. - #table_name
-
#tls : Bool
#tls
getter -
#tls=(value : Bool)
#tls
setter - #tls? : Bool | Nil
- #tls_assigned? : Bool
-
#tls_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
- #tls_changed? : Bool
-
#tls_default : Bool
#tls
's default value - #tls_present? : Bool
- #tls_was : Bool | Nil
-
#tls_will_change! : Nil
Include
#tls
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. -
#username : String | Nil
#username
getter -
#username=(value : String | Nil)
#username
setter - #username_assigned? : Bool
-
#username_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
- #username_changed? : Bool
-
#username_default : String | Nil
#username
's default value - #username_present? : Bool
- #username_was : String | Nil | Nil
-
#username_will_change! : Nil
Include
#username
in the set of changed attributes, whether it has changed or not. -
#validate_nilability
Validate that all non-nillable fields have values.
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
reset_associations
reset_associations
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::Broker 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.
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
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #auth_type
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
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 #certificate
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 #description
in the set of changed attributes, whether it has changed or not.
Regex filters for sensitive data. Matches will be replaced with a hmac_256(secret, match).
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Regex filters for sensitive data. Matches will be replaced with a hmac_256(secret, match).
Include #filters
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 #host
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.
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 #name
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 #password
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 #port
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
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #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
Include #tls
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