class ActiveModel::AttributeSet::YAMLEncoder
:nodoc:
ActiveModel::AttributeSet to reduce the size of the resulting string
Attempts to do more intelligent YAML dumping of an
def decode(coder)
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
def encode(attribute_set, coder)
def encode(attribute_set, coder) coder["concise_attributes"] = attribute_set.each_value.map do |attr| if attr.type.equal?(default_types[attr.name]) attr.with_type(nil) else attr end end end
def initialize(default_types)
ActiveModel::AttributeSet to reduce the size of the resulting string
Attempts to do more intelligent YAML dumping of an
def initialize(default_types) @default_types = default_types end