abstract class ActiveModel::Model
- ActiveModel::Model
- Reference
- Object
Included Modules
- DB::Mappable
- DB::Serializable
- JSON::Serializable
- YAML::Serializable
Defined in:
active-model/model.crConstructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(pull : JSON::PullParser)
- .new(rs : DB::ResultSet)
Class Method Summary
Instance Method Summary
-
#apply_defaults
Stub methods to prevent compiler errors
- #changed?
- #changed_attributes
- #clear_changes_information
Macro Summary
-
__customize_orm__
For overriding in parent classes
- __getters__
- __nilability_validation__
-
attribute(name, mass_assignment = true, persistence = true, show = false, serialization_group = [] of Symbol, **tags, &block)
Declare an
ActiveModel::Model
attribute - define_to_json(group, except = [] of Symbol, only = [] of Symbol, methods = [] of Symbol)
Constructor Detail
Class Method Detail
Instance Method Detail
Macro Detail
macro attribute(name, mass_assignment = true, persistence = true, show = false, serialization_group = [] of Symbol, **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
: Emitnull
if value isnil
, key is omitted ifjson_emit_null
isfalse
.json_root
: Assume value is inside a JSON object under the provided key.
YAML
yaml_key
: Override the emitted YAML key.yaml_emit_null
: Emitnull
if value isnil
, key is omitted ifyaml_emit_null
isfalse
.yaml_root
: Assume value is inside a YAMLk object under the provided key.