ActiveModel::Model
Inherits DB::Mappable / DB::Serializable / YAML::Serializable / JSON::Serializable / Reference / Object
Constructors
new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Sourcenew(pull : JSON::PullParser)
Sourcenew(rs : DB::ResultSet)
Sourcenew(*, __pull_for_json_serializable pull : JSON::PullParser)
Sourcenew(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
SourceClass methods
from_rs(rs : DB::ResultSet)
SourceInstance methods
changed?
Sourcechanged_attributes
Sourceclear_changes_information
SourceMacros
__getters__
Source__nilability_validation__
Sourceattribute(name, mass_assignment = true, persistence = true, show = false, serialization_group = [] of Symbol, sanitize = nil, **tags, &block)
Declare an ActiveModel::Model attribute
General Arguments
persistence: Will not emit the key when serializing iffalse.converter: A module defining alternative serialisation behaviour for the attribute's value.
Serialisation Target Arguments
Additionally, attribute accepts the following optional arguments for different serialisation targets.
JSON
json_key: Override the emitted JSON key.json_emit_null: Emitnullif value isnil, key is omitted ifjson_emit_nullisfalse.json_root: Assume value is inside a JSON object under the provided key.
YAML
yaml_key: Override the emitted YAML key.yaml_emit_null: Emitnullif value isnil, key is omitted ifyaml_emit_nullisfalse.yaml_root: Assume value is inside a YAMLk object under the provided key.
define_to_json(group, except = [] of Symbol, only = [] of Symbol, methods = [] of Symbol)
Source