module Ktistec::Model::InstanceMethods
Direct including types
- Account
- ActivityPub::Activity
- ActivityPub::Actor
- ActivityPub::Collection
- ActivityPub::Object
- FilterTerm
- LastTime
- Point
- Relationship
- Session
- Tag
- Task
Defined in:
framework/model.crConstructors
-
.new(properties : Hash(String, Any), *, _strict : Bool = false) forall Any
Initializes a new instance.
-
.new(*, _strict : Bool = false, **properties)
Initializes a new instance.
Macro Summary
-
belongs_to(name, primary_key = id, foreign_key = nil, class_name = nil, inverse_of = nil)
Specifies a one-to-one association with another model.
-
derived(decl, *, aliased_to)
Specifies a property that is derived from another property.
-
has_many(name, primary_key = id, foreign_key = nil, class_name = nil, inverse_of = nil)
Specifies a one-to-many association with another model.
-
has_one(name, primary_key = id, foreign_key = nil, class_name = nil, inverse_of = nil)
Specifies a one-to-one association with another model.
-
validates(property, &block)
Adds a validation to a property on an instance.
Instance Method Summary
-
#==(other)
Returns true if all persistent properties are equal.
- #_run_validations
- #_save_model(skip_validation = false)
- #_serialize_graph(nodes, association = nil, index = nil, skip_associated = false)
-
#assign(properties : Hash(String, Any), *, _strict : Bool = false) forall Any
Bulk assigns properties.
-
#assign(*, _strict : Bool = false, **properties)
Bulk assigns properties.
- #changed!(*properties : Symbol)
- #changed?
- #changed?(*properties : Symbol)
- #clear!
- #clear!(*properties : Symbol)
-
#destroy
Destroys the instance.
- #destroyed?
- #errors
-
#hash(hasher)
Computes the hash for this instance.
- #inspect(io : IO)
- #new_record?
-
#reload!
Reloads the properties from the database.
-
#save(skip_validation = false, skip_associated = false)
Saves the instance.
- #serialize_graph(skip_associated = false)
-
#table_name
Returns the table name.
- #to_h
- #to_json(json : JSON::Builder)
- #to_s(io : IO)
-
#update_property(property, value)
Updates and persists property value.
-
#valid?(skip_associated = false)
Returns true if the instance is valid.
-
#validate(skip_associated = false)
Validates the instance and returns any errors.
Constructor Detail
Initializes a new instance.
Specified properties are assigned via setter methods. If a property lacks a setter the property is read-only and cannot be assigned. Non-nilable properties must be assigned.
To allow initialization of multiple models from a single
collection of properties, initialize
ignores specified
properties that do not exist on the model. Specify _strict: true
to change this behavior to raise an error instead.
Initializes a new instance.
Specified properties are assigned via setter methods. If a property lacks a setter the property is read-only and cannot be assigned. Non-nilable properties must be assigned.
To allow initialization of multiple models from a single
collection of properties, initialize
ignores specified
properties that do not exist on the model. Specify _strict: true
to change this behavior to raise an error instead.
Macro Detail
Specifies a one-to-one association with another model.
Specifies a one-to-many association with another model.
Specifies a one-to-one association with another model.
Adds a validation to a property on an instance.
validates xyz { "is blank" if xyz.blank? }
Instance Method Detail
Bulk assigns properties.
Specified properties are assigned via setter methods. If a property lacks a setter the property is read-only and cannot be assigned.
To allow assignment of multiple models from a single
collection of properties, #assign
ignores specified
properties that do not exist on the model. Specify _strict: true
to change this behavior to raise an error instead.
Bulk assigns properties.
Specified properties are assigned via setter methods. If a property lacks a setter the property is read-only and cannot be assigned.
To allow assignment of multiple models from a single
collection of properties, #assign
ignores specified
properties that do not exist on the model. Specify _strict: true
to change this behavior to raise an error instead.
Reloads the properties from the database.
Only reloads the persistent properties. Does not trigger any side effects. Does not ensure that the instance's state is otherwise valid.
Updates and persists property value.
This method is meant for simple state changes -- it does not
validate model state or run before and after actions! Prefer
assign/save
methods.