Class: Representable::YAML::PropertyBinding
- Inherits:
-
Hash::PropertyBinding
- Object
- Binding
- Hash::PropertyBinding
- Representable::YAML::PropertyBinding
- Defined in:
- lib/representable/bindings/yaml_bindings.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Binding
Instance Method Summary collapse
-
#initialize(definition) ⇒ PropertyBinding
constructor
FIXME.
- #serialize_for(value) ⇒ Object
- #write(map, value) ⇒ Object
- #write_scalar(value) ⇒ Object
Methods inherited from Hash::PropertyBinding
Methods inherited from Binding
Constructor Details
#initialize(definition) ⇒ PropertyBinding
FIXME. make generic.
22 23 24 25 |
# File 'lib/representable/bindings/yaml_bindings.rb', line 22 def initialize(definition) # FIXME. make generic. super extend ObjectBinding if definition.typed? end |
Instance Method Details
#serialize_for(value) ⇒ Object
32 33 34 |
# File 'lib/representable/bindings/yaml_bindings.rb', line 32 def serialize_for(value) write_scalar serialize(value) end |
#write(map, value) ⇒ Object
27 28 29 30 |
# File 'lib/representable/bindings/yaml_bindings.rb', line 27 def write(map, value) map.children << Psych::Nodes::Scalar.new(definition.from) map.children << serialize_for(value) # FIXME: should be serialize. end |
#write_scalar(value) ⇒ Object
36 37 38 |
# File 'lib/representable/bindings/yaml_bindings.rb', line 36 def write_scalar(value) Psych::Nodes::Scalar.new(value.to_s) end |