abstract class ActiveModel::Model

Included Modules

Defined in:

active-model/model.cr

Constructors

Class Method Summary

Instance Method Summary

Macro Summary

Constructor Detail

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

[View source]
def self.new(pull : JSON::PullParser) #

[View source]
def self.new(rs : DB::ResultSet) #

[View source]

Class Method Detail

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

[View source]

Instance Method Detail

def apply_defaults #

Stub methods to prevent compiler errors


[View source]
def changed? #

[View source]
def changed_attributes #

[View source]
def clear_changes_information #

[View source]

Macro Detail

macro __customize_orm__ #

For overriding in parent classes


[View source]
macro __getters__ #

[View source]
macro __nilability_validation__ #

[View source]
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 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.

[View source]
macro define_to_json(group, except = [] of Symbol, only = [] of Symbol, methods = [] of Symbol) #

[View source]