class PlaceOS::Model::JsonSchema

Included Modules

Defined in:

placeos-models/json_schema.cr

Constant 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

Class Method Summary

Instance Method Summary

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(id : String | Nil | Missing = Missing)
assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
assign_attributes
, attributes attributes, attributes_tuple attributes_tuple, before_create before_create, before_destroy before_destroy, before_save before_save, before_update before_update, 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

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

attributes : Array(Symbol) attributes

Constructor Detail

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.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

def self.new(created_at : Time | Nil = nil, updated_at : Time | Nil = nil, name : String | Nil = nil, description : String | Nil = nil, schema : JSON::Any | Nil = nil, id : String | Nil | Nil = nil) #

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

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


Class Method Detail

def self.attributes : Array(Symbol) #

Returns all attribute keys.


def self.elastic #

def self.table_name #

Instance Method Detail

def after_create #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def after_destroy #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def after_save #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def after_update #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def apply_defaults #

Generate code to apply default values


def assign_attributes(created_at : Time | Missing = Missing, updated_at : Time | Missing = Missing, name : String | Missing = Missing, description : String | Missing = Missing, schema : JSON::Any | Missing = Missing, id : 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_from_json(json) #

def assign_attributes_from_trusted_json(json) #

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 before_create #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def before_destroy #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def before_save #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def before_update #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
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 created_at : Time #

#created_at getter


def created_at=(value : Time) #

Override the map json #created_at setter


def created_at_change #

Returns { created_at_was, created_at } if #created_at has changed.


def created_at_changed? #

Check if #created_at is in the set of changed attributes.


def created_at_default : Time #

#created_at's default value


def created_at_was : Time? #

Returns the previous value of #created_at.


def created_at_will_change! #

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


def description : String #

#description getter


def description=(value : String) #

#description setter


def description_change #

Returns { description_was, description } if #description has changed.


def description_changed? #

Check if #description is in the set of changed attributes.


def description_default : String #

#description's default value


[View source]
def description_was : String? #

Returns the previous value of #description.


def description_will_change! #

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


def id : String | Nil #

#id getter


def id=(value : String | Nil) #

#id setter


def id_change #

Returns { id_was, id } if #id has changed.


def id_changed? #

Check if #id is in the set of changed attributes.


def id_was : String? #

Returns the previous value of #id.


def id_will_change! #

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


def metadata #

[View source]
def name : String #

#name getter


def name=(value : String) #

#name setter


def name_change #

Returns { name_was, name } if #name has changed.


def name_changed? #

Check if #name is in the set of changed attributes.


def name_default : String #

#name's default value


[View source]
def name_was : String? #

Returns the previous value of #name.


def name_will_change! #

Include #name 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 run_create_callbacks(&) #

Wrap a block with callbacks for the appropriate crud operation


[View source]
def run_destroy_callbacks(&) #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def run_save_callbacks(&) #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def run_update_callbacks(&) #
Description copied from class PlaceOS::Model::ModelBase

Base class for all Engine models


[View source]
def schema : JSON::Any #

#schema getter


def schema=(value : JSON::Any) #

#schema setter


def schema_change #

Returns { schema_was, schema } if #schema has changed.


def schema_changed? #

Check if #schema is in the set of changed attributes.


def schema_default : JSON::Any #

#schema's default value


[View source]
def schema_was : JSON::Any? #

Returns the previous value of #schema.


def schema_will_change! #

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


def table_name #

def to_json(json : JSON::Builder) #

def to_yaml(__temp_1413 : YAML::Nodes::Builder) #

def updated_at : Time #

#updated_at getter


def updated_at=(value : Time) #

#updated_at setter


def updated_at_change #

Returns { updated_at_was, updated_at } if #updated_at has changed.


def updated_at_changed? #

Check if #updated_at is in the set of changed attributes.


def updated_at_default : Time #

#updated_at's default value


def updated_at_was : Time? #

Returns the previous value of #updated_at.


def updated_at_will_change! #

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


def validate_nilability #

Validate that all non-nillable fields have values.