class PlaceOS::Model::Authority
- PlaceOS::Model::Authority
- PlaceOS::Model::ModelBase
- PgORM::Base
- ActiveModel::Model
- Reference
- Object
Included Modules
Defined in:
placeos-models/authority.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: [:destroy_ldap_authentications, :destroy_oauth_authentications, :destroy_saml_authentications, :destroy_users] 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, name : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, description : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, domain : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, login_url : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, logout_url : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, internals : Hash(String, JSON::Any) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, config : Hash(String, JSON::Any) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, email_domains : 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::Authority 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
-
.find_by_domain(domain : String) : Authority | Nil
Locates an authority by its unique domain name
-
.find_by_email(email : String) : Authority | Nil
Locates an authority by email domain
- .from_rs(__temp_926 : DB::ResultSet)
- .on_error(err : Exception | IO::Error)
- .primary_key : Symbol
- .table_name
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, name : String | Missing = Missing, description : String | Missing = Missing, domain : String | Missing = Missing, login_url : String | Missing = Missing, logout_url : String | Missing = Missing, internals : Hash(String, JSON::Any) | Missing = Missing, config : Hash(String, JSON::Any) | Missing = Missing, email_domains : 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::Authority)
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.
-
#config : Hash(String, JSON::Any)
#config
getter -
#config=(value : Hash(String, JSON::Any))
#config
setter -
#config? : Hash(String, JSON::Any) | Nil
Assign instance variable to correct type
- #config_assigned? : Bool
-
#config_change : Tuple(Hash(String, JSON::Any) | Nil, Hash(String, JSON::Any) | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #config_changed? : Bool
-
#config_default : Hash(String, JSON::Any)
#config
's default value - #config_present? : Bool
- #config_was : Hash(String, JSON::Any) | Nil
-
#config_will_change! : Nil
Include
#config
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
Assign instance variable to correct type
- #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
Assign instance variable to correct type
- #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. - #destroy_ldap_authentications
- #destroy_oauth_authentications
- #destroy_saml_authentications
- #destroy_users
-
#domain : String
#domain
getter -
#domain=(value : String)
Ensure only the host is saved.
-
#domain? : String | Nil
Assign instance variable to correct type
- #domain_assigned? : Bool
-
#domain_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
- #domain_changed? : Bool
-
#domain_default : String
#domain
's default value - #domain_present? : Bool
- #domain_was : String | Nil
-
#domain_will_change! : Nil
Include
#domain
in the set of changed attributes, whether it has changed or not. -
#email_domains : Array(String)
#email_domains
getter -
#email_domains=(value : Array(String))
#email_domains
setter -
#email_domains? : Array(String) | Nil
Assign instance variable to correct type
- #email_domains_assigned? : Bool
-
#email_domains_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
- #email_domains_changed? : Bool
-
#email_domains_default : Array(String)
#email_domains
's default value - #email_domains_present? : Bool
- #email_domains_was : Array(String) | Nil
-
#email_domains_will_change! : Nil
Include
#email_domains
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. -
#internals : Hash(String, JSON::Any)
#internals
getter -
#internals=(value : Hash(String, JSON::Any))
#internals
setter -
#internals? : Hash(String, JSON::Any) | Nil
Assign instance variable to correct type
- #internals_assigned? : Bool
-
#internals_change : Tuple(Hash(String, JSON::Any) | Nil, Hash(String, JSON::Any) | Nil) | Nil
Returns a Tuple of the previous and the current value of an instance variable if it has changed
- #internals_changed? : Bool
-
#internals_default : Hash(String, JSON::Any)
#internals
's default value - #internals_present? : Bool
- #internals_was : Hash(String, JSON::Any) | Nil
-
#internals_will_change! : Nil
Include
#internals
in the set of changed attributes, whether it has changed or not. -
#invoke_props
Base class for all Engine models
- #ldap_authentications
-
#login_url : String
#login_url
getter -
#login_url=(value : String)
#login_url
setter -
#login_url? : String | Nil
TODO feature request: autogenerate login url
- #login_url_assigned? : Bool
-
#login_url_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
- #login_url_changed? : Bool
-
#login_url_default : String
#login_url
's default value -
#login_url_present? : Bool
TODO feature request: autogenerate login url
- #login_url_was : String | Nil
-
#login_url_will_change! : Nil
Include
#login_url
in the set of changed attributes, whether it has changed or not. -
#logout_url : String
#logout_url
getter -
#logout_url=(value : String)
#logout_url
setter -
#logout_url? : String | Nil
Assign instance variable to correct type
- #logout_url_assigned? : Bool
-
#logout_url_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
- #logout_url_changed? : Bool
-
#logout_url_default : String
#logout_url
's default value - #logout_url_present? : Bool
- #logout_url_was : String | Nil
-
#logout_url_will_change! : Nil
Include
#logout_url
in the set of changed attributes, whether it has changed or not. -
#name : String
#name
getter -
#name=(value : String)
#name
setter -
#name? : String | Nil
Assign instance variable to correct type
- #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. - #oauth_authentications
-
#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.
-
#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
- #saml_authentications
- #table_name
-
#updated_at : Time
#updated_at
getter -
#updated_at=(value : Time)
#updated_at
setter -
#updated_at? : Time | Nil
Assign instance variable to correct type
- #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. - #users
-
#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
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::Authority 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.
Locates an authority by its unique domain name
Locates an authority by email domain
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 #config
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.
Returns a Tuple of the previous and the current value of an instance variable if it has changed
Include #domain
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 #email_domains
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 #internals
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 #login_url
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 #logout_url
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 #name
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 #updated_at
in the set of changed attributes, whether it has changed or not.