Class: Representable::YAML::CollectionBinding

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

Instance Attribute Summary

Attributes inherited from Binding

#lambda_context, #represented, #user_options

Instance Method Summary collapse

Methods inherited from PropertyBinding

build_for, #initialize, #write, #write_scalar

Methods inherited from Hash::PropertyBinding

build_for, #initialize, #read, #write

Methods inherited from Binding

build, #compile_fragment, #definition, #deserialize, #get, #initialize, #read_fragment, #read_fragment_for, #serialize, #set, #uncompile_fragment, #write_fragment, #write_fragment_for

Constructor Details

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

Instance Method Details

#deserialize_from(fragment) ⇒ Object

FIXME: redundant from Hash::Bindings



55
56
57
# File 'lib/representable/bindings/yaml_bindings.rb', line 55

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

#serialize_for(value) ⇒ Object



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

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