class

PlaceOS::Model::Driver

Inherits PlaceOS::Model::Utilities::SettingsHelper < PlaceOS::Model::Timestamps < PlaceOS::Model::ModelBase < PlaceOS::Model::Associations < Neuroplastic < PgORM::Base < PgORM::Validators < PgORM::Table < PgORM::Persistence < PgORM::Associations < ActiveModel::Callbacks < ActiveModel::Validation < ActiveModel::Model < DB::Mappable < DB::Serializable < YAML::Serializable < JSON::Serializable < Reference < Object

Constants

CALLBACKS = { before_save: [:check_update_available] of Nil, after_save: [:update_modules] 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_settings_and_versions, :cleanup_modules] of Nil, after_destroy: [] of Nil, }
Log = ::Log.for(self)
PRIMARY_KEY_TYPES = {:id => (String | Nil)} of Nil => Nil

macro level key => type

PRIMARY_KEYS = [{:id}]
RECOMPILE_PREFIX = "RECOMPILE-"

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)
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, json_schema : JSON::Any | ActiveModel::Model::None = ::ActiveModel::Model::None.new, default_uri : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, default_port : Int32 | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, role : PlaceOS::Model::Driver::Role | ActiveModel::Model::None = ::ActiveModel::Model::None.new, alert_level : PlaceOS::Model::Alert::Severity | ActiveModel::Model::None = ::ActiveModel::Model::None.new, file_name : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, commit : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, compilation_output : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, module_name : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, ignore_connected : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, update_available : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, update_info : PlaceOS::Model::Driver::UpdateInfo | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, repository_id : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new)

Initialize PlaceOS::Model::Driver from HTTP::Params.

Class methods

attributes

Returns all attribute keys.

by_repository_id(id)

Look up instances of this model dependent on the foreign key

Source
changes(id : String | Nil | Nil = nil) : ChangeFeed

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.

elastic
from_rs(__temp_1916 : DB::ResultSet)
on_error(err : Exception | IO::Error)
primary_key

Base class for all Engine models

Source
require_updates

Returns the list of Drivers which has update available

Source
table_name

Instance methods

__repository

Association ##############################################################################################

__repository=(__repository : Repository | Nil)

Association ##############################################################################################

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

alert_level

alert_level getter

alert_level=(value : PlaceOS::Model::Alert::Severity)

alert_level setter

alert_level?

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.

alert_level_assigned?
alert_level_change

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

alert_level_changed?
alert_level_default

alert_level's default value

Source
alert_level_present?
alert_level_removed?
alert_level_was
alert_level_will_change!

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

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, json_schema : JSON::Any | Missing = Missing, default_uri : String | Nil | Missing = Missing, default_port : Int32 | Nil | Missing = Missing, role : PlaceOS::Model::Driver::Role | Missing = Missing, alert_level : PlaceOS::Model::Alert::Severity | Missing = Missing, file_name : String | Missing = Missing, commit : String | Missing = Missing, compilation_output : String | Nil | Missing = Missing, module_name : String | Missing = Missing, ignore_connected : Bool | Missing = Missing, update_available : Bool | Missing = Missing, update_info : PlaceOS::Model::Driver::UpdateInfo | Nil | Missing = Missing, repository_id : 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 multiple attributes via HTTP::Params.

assign_attributes(model : PlaceOS::Model::Driver)

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

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

Serialize the set of changed attributes to YAML.

clear_changes_information

Reset changes for all attributes.

commit

commit getter

commit=(value : String)

commit setter

commit?

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.

commit_assigned?
commit_change

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

commit_changed?
commit_default

commit's default value

Source
commit_present?

Commit/version of driver to compile

commit_removed?
commit_was
commit_will_change!

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

compilation_output

compilation_output getter

compilation_output=(value : String | Nil)

compilation_output setter

compilation_output_assigned?
compilation_output_change

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

compilation_output_changed?
compilation_output_default

compilation_output's default value

Source
compilation_output_present?

Output of the last failed compilation

compilation_output_removed?
compilation_output_was
compilation_output_will_change!

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

created_at

created_at getter

created_at=(value : Time)

Setters created_at setter

created_at?

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.

created_at_assigned?
created_at_change

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

created_at_changed?
created_at_default

created_at's default value

created_at_present?
created_at_removed?
created_at_was
created_at_will_change!

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

default_port

default_port getter

default_port=(value : Int32 | Nil)

default_port setter

default_port=(port)
Source
default_port_assigned?
default_port_change

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

default_port_changed?
default_port_default

default_port's default value

Source
default_port_present?
default_port_removed?
default_port_was
default_port_will_change!

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

default_uri

default_uri getter

default_uri=(value : String | Nil)

default_uri setter

default_uri=(uri)
Source
default_uri_assigned?
default_uri_change

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

default_uri_changed?
default_uri_default

default_uri's default value

Source
default_uri_present?
default_uri_removed?
default_uri_was
default_uri_will_change!

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

description

description getter

description=(value : String)

description setter

description?

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.

description_assigned?
description_change

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

description_changed?
description_default

description's default value

Source
description_present?
description_removed?
description_was
description_will_change!

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

destroy_settings_and_versions

Encrypted yaml settings

file_name

file_name getter

file_name=(value : String)

file_name setter

file_name?

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.

file_name_assigned?
file_name_change

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

file_name_changed?
file_name_default

file_name's default value

Source
file_name_present?

Path to driver, relative to repository directory

file_name_removed?
file_name_was
file_name_will_change!

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

id

id getter

id=(value : String | Nil)

id setter

id?
id_assigned?
id_change

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

id_changed?
id_default

id's default value

id_present?
id_removed?
id_was
id_will_change!

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

ignore_connected

ignore_connected getter

ignore_connected=(value : Bool)

ignore_connected setter

ignore_connected?

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.

ignore_connected_assigned?
ignore_connected_change

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

ignore_connected_changed?
ignore_connected_default

ignore_connected's default value

Source
ignore_connected_present?

Don't include this module in statistics or disconnected searches Might be a device that commonly goes offline (like a PC or Display that only supports Wake on Lan)

ignore_connected_removed?
ignore_connected_was
ignore_connected_will_change!

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

invoke_props

Base class for all Engine models

json_schema

json_schema getter

json_schema=(value : JSON::Any)

json_schema setter

json_schema?

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.

json_schema_assigned?
json_schema_change

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

json_schema_changed?
json_schema_default

json_schema's default value

Source
json_schema_present?
json_schema_removed?
json_schema_was
json_schema_will_change!

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

module_name

module_name getter

module_name=(value : String)

module_name setter

module_name?

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.

module_name_assigned?
module_name_change

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

module_name_changed?
module_name_default

module_name's default value

Source
module_name_present?

Module instance configuration

module_name_removed?
module_name_was
module_name_will_change!

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

modules

Find the modules that rely on this driver

Source
name

name getter

name=(value : String)

name setter

name?

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.

name_assigned?
name_change

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

name_changed?
name_default

name's default value

Source
name_present?
name_removed?
name_was
name_will_change!

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

persistent_attributes

Returns a Hash of all attributes that can be persisted.

primary_key

Base class for all Engine models

Source
primary_key_hash
process_update_info(info : UpdateInfo)
Source
recompile(commit_hash : String | Nil = nil)

Sets the commit hash of the driver for a recompile event

Source
recompile_commit?

Returns the commit hash if the driver has a recompile commit hash

Source
repository

Retrieves the parent relationship

Source
repository!

Association ##############################################################################################

Source
repository=(parent : Repository)

Sets the parent relationship

Source
repository_id

repository_id getter

repository_id=(value : String)

repository_id setter

repository_id?

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.

repository_id_assigned?
repository_id_change

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

repository_id_changed?
repository_id_default

repository_id's default value

repository_id_present?

Association ##############################################################################################

repository_id_removed?
repository_id_was
repository_id_will_change!

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

reset_associations

Association ##############################################################################################

Source
restore_attributes

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

role

role getter

role setter

role?

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.

role_assigned?
role_change

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

role_changed?
role_default

role's default value

Source
role_present?
role_removed?
role_was
role_will_change!

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

settings_and_versions

Encrypted yaml settings

Source
settings_hierarchy
Source
table_name
update_available

update_available getter

update_available=(value : Bool)

update_available setter

update_available?

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.

update_available_assigned?
update_available_change

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

update_available_changed?
update_available_default

update_available's default value

Source
update_available_present?
update_available_removed?
update_available_was
update_available_will_change!

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

update_info

update_info getter

update_info=(value : PlaceOS::Model::Driver::UpdateInfo | Nil)

update_info setter

update_info_assigned?
update_info_change

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

update_info_changed?
update_info_default

update_info's default value

Source
update_info_present?
update_info_removed?
update_info_was
update_info_will_change!

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

updated_at

updated_at getter

updated_at=(value : Time)

updated_at setter

updated_at?

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.

updated_at_assigned?
updated_at_change

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

updated_at_changed?
updated_at_default

updated_at's default value

updated_at_present?
updated_at_removed?
updated_at_was
updated_at_will_change!

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.

Nested types