class Representable::YAML::Binding

Public Class Methods

build_for(definition) click to toggle source
# File lib/representable/yaml/binding.rb, line 6
def self.build_for(definition)
  return Collection.new(definition) if definition.array?

  new(definition)
end

Public Instance Methods

deserialize_method() click to toggle source
# File lib/representable/yaml/binding.rb, line 32
def deserialize_method
  :from_hash
end
node_for(fragment) click to toggle source

private

# File lib/representable/yaml/binding.rb, line 18
def node_for(fragment)
  write_scalar(fragment)
end
serialize_method() click to toggle source
# File lib/representable/yaml/binding.rb, line 28
def serialize_method
  :to_ast
end
write(map, fragment, as) click to toggle source
# 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) click to toggle source
# File lib/representable/yaml/binding.rb, line 22
def write_scalar(value)
  return value if typed?

  Psych::Nodes::Scalar.new(value.to_s)
end