abstract class PlaceOS::Model::ModelBase

Overview

Base class for all Engine models

Included Modules

Direct Known Subclasses

Defined in:

placeos-models/base/model.cr

Constant Summary

CALLBACKS = {before_save: [do if self.id? else self.id = Utilities::IdGenerator.next(self) end end] of Nil, after_save: [] of Nil, before_create: [do if self.id? else self.id = Utilities::IdGenerator.next(self) end end] of Nil, after_create: [] of Nil, before_update: [] of Nil, after_update: [] of Nil, before_destroy: [] of Nil, after_destroy: [] of Nil}

Base class for all Engine models

Constructors

Class Method Summary

Instance Method Summary

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

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

Base class for all Engine models


def self.new(pull : JSON::PullParser) #

Base class for all Engine models


def self.new(rs : DB::ResultSet) #

Base class for all Engine models


Class Method Detail

def self.attributes : Array(Symbol) #

Returns all attribute keys.


def self.auto_generate_id : Bool #

Base class for all Engine models


def self.from_rs(rs : DB::ResultSet) #

Base class for all Engine models


def self.primary_key : Symbol #

Base class for all Engine models


Instance Method Detail

def after_create #

Base class for all Engine models


def after_destroy #

Base class for all Engine models


def after_save #

Base class for all Engine models


def after_update #

Base class for all Engine models


def apply_defaults #

Generate code to apply default values


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

Assign to mulitple attributes via HTTP::Params.


def assign_attributes(model : PlaceOS::Model::ModelBase) #

Assign to multiple attributes from a model object


def assign_attributes #

Assign to multiple attributes.


def attributes #

Returns a Hash of all attribute values


def attributes_tuple #

Returns a NamedTuple of all attribute values.


def before_create #

Base class for all Engine models


def before_destroy #

Base class for all Engine models


def before_save #

Base class for all Engine models


def before_update #

Base class for all Engine models


def invoke_props #

Base class for all Engine models


def persistent_attributes #

Returns a Hash of all attributes that can be persisted.


def run_create_callbacks(&) #

Wrap a block with callbacks for the appropriate crud operation


def run_destroy_callbacks(&) #

Base class for all Engine models


def run_save_callbacks(&) #

Base class for all Engine models


def run_update_callbacks(&) #

Base class for all Engine models