class DuckRecord::MetaStrictRecord

Attributes

raw_attributes[RW]

Public Class Methods

_embeds_reflections() click to toggle source
# File lib/duck_record/meta_strict_record.rb, line 11
def _embeds_reflections
  _reflections.select { |_, v| v.is_a? DuckRecord::Reflection::EmbedsAssociationReflection }
end
dump(obj) click to toggle source
# File lib/duck_record/meta_strict_record.rb, line 15
def dump(obj)
  serializable_hash =
    if obj.respond_to?(:serializable_hash)
      obj.serializable_hash
    elsif obj.respond_to?(:to_hash)
      obj.to_hash
    else
      raise ArgumentError, "`obj` required can be cast to `Hash` -- #{obj.class}"
    end.stringify_keys
    return serializable_hash
end
load(hash) click to toggle source
# File lib/duck_record/meta_strict_record.rb, line 27
def load(hash)
  case hash
  when Hash
    record = new hash
    record.raw_attributes = hash.with_indifferent_access
    return record
  else
    new
  end
end

Public Instance Methods

serializable_hash(options = {}) click to toggle source
Calls superclass method
# File lib/duck_record/meta_strict_record.rb, line 5
def serializable_hash(options = {})
  options = (options || {}).reverse_merge include: self.class._embeds_reflections.keys
  super options
end