Class: Representable::YAML::Binding
- Inherits:
-
Hash::Binding
- Object
- Hash::Binding
- Representable::YAML::Binding
- Defined in:
- lib/representable/yaml/binding.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Collection
Class Method Summary collapse
Instance Method Summary collapse
- #deserialize_method ⇒ Object
-
#node_for(fragment) ⇒ Object
private.
- #serialize_method ⇒ Object
- #write(map, fragment, as) ⇒ Object
- #write_scalar(value) ⇒ Object
Class Method Details
.build_for(definition) ⇒ Object
6 7 8 9 10 |
# File 'lib/representable/yaml/binding.rb', line 6 def self.build_for(definition) return Collection.new(definition) if definition.array? new(definition) end |
Instance Method Details
#deserialize_method ⇒ Object
32 33 34 |
# File 'lib/representable/yaml/binding.rb', line 32 def deserialize_method :from_hash end |
#node_for(fragment) ⇒ Object
private
18 19 20 |
# File 'lib/representable/yaml/binding.rb', line 18 def node_for(fragment) write_scalar(fragment) end |
#serialize_method ⇒ Object
28 29 30 |
# File 'lib/representable/yaml/binding.rb', line 28 def serialize_method :to_ast end |
#write(map, fragment, as) ⇒ Object
12 13 14 15 |
# File 'lib/representable/yaml/binding.rb', line 12 def write(map, fragment, as) map.children << Psych::Nodes::Scalar.new(as) map.children << node_for(fragment) # FIXME: should be serialize. end |
#write_scalar(value) ⇒ Object
22 23 24 25 26 |
# File 'lib/representable/yaml/binding.rb', line 22 def write_scalar(value) return value if typed? Psych::Nodes::Scalar.new(value.to_s) end |