class

ActiveModel::Model

Inherits DB::Mappable / DB::Serializable / YAML::Serializable / JSON::Serializable / Reference / Object

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(pull : JSON::PullParser)
Source
new(rs : DB::ResultSet)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Class methods

from_rs(rs : DB::ResultSet)
Source

Instance methods

apply_defaults

Stub methods to prevent compiler errors

Source
changed?
Source
changed_attributes
Source
clear_changes_information
Source

Macros

__customize_orm__

For overriding in parent classes

Source
__getters__
Source
__nilability_validation__
Source
attribute(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 if false.
  • 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: Emit null if value is nil, key is omitted if json_emit_null is false.
  • json_root: Assume value is inside a JSON object under the provided key.

YAML

  • yaml_key: Override the emitted YAML key.
  • yaml_emit_null: Emit null if value is nil, key is omitted if yaml_emit_null is false.
  • yaml_root: Assume value is inside a YAMLk object under the provided key.
Source
define_to_json(group, except = [] of Symbol, only = [] of Symbol, methods = [] of Symbol)
Source

Nested types