Class: Representable::YAML::CollectionBinding

Inherits:
PropertyBinding show all
Defined in:
lib/representable/bindings/yaml_bindings.rb

Instance Attribute Summary

Attributes inherited from Binding

#definition

Instance Method Summary collapse

Methods inherited from PropertyBinding

#initialize, #write, #write_scalar

Methods inherited from Hash::PropertyBinding

#initialize, #read, #write

Methods inherited from Binding

#deserialize, #initialize, #serialize

Constructor Details

This class inherits a constructor from Representable::YAML::PropertyBinding

Instance Method Details

#deserialize_from(fragment) ⇒ Object

FIXME: redundant from Hash::Bindings



50
51
52
# File 'lib/representable/bindings/yaml_bindings.rb', line 50

def deserialize_from(fragment)  # FIXME: redundant from Hash::Bindings
  fragment.collect { |item_fragment| deserialize(item_fragment) }
end

#serialize_for(value) ⇒ Object



43
44
45
46
47
48
# File 'lib/representable/bindings/yaml_bindings.rb', line 43

def serialize_for(value)
  Psych::Nodes::Sequence.new.tap do |seq|
    seq.style = Psych::Nodes::Sequence::FLOW if definition.options[:style] == :flow
    value.each { |obj| seq.children << super(obj) }
  end
end