Method: ActiveModel::AttributeSet::YAMLEncoder#decode

Defined in:
activemodel/lib/active_model/attribute_set/yaml_encoder.rb

#decode(coder) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'activemodel/lib/active_model/attribute_set/yaml_encoder.rb', line 22

def decode(coder)
  if coder["attributes"]
    coder["attributes"]
  else
    attributes_hash = Hash[coder["concise_attributes"].map do |attr|
      if attr.type.nil?
        attr = attr.with_type(default_types[attr.name])
      end
      [attr.name, attr]
    end]
    AttributeSet.new(attributes_hash)
  end
end