Parent

SafeYAML::SyckResolver

Constants

QUOTE_STYLES

Public Instance Methods

resolve_map(node) click to toggle source
# File lib/safe_yaml/syck_resolver.rb, line 18
def resolve_map(node)
  map = node.value

  hash = {}

  # Take the "<<" key nodes first, as these are meant to approximate a form of inheritance.
  inheritors = map.keys.select { |node| resolve_node(node) == "<<" }
  inheritors.each do |key|
    value_node = map.delete(key)
    hash.merge!(resolve_node(value_node))
  end

  # All that's left should be normal (non-"<<") nodes.
  map.each do |key_node, value_node|
    hash[resolve_node(key_node)] = resolve_node(value_node)
  end

  return hash
end
resolve_node(node) click to toggle source
# File lib/safe_yaml/syck_resolver.rb, line 5
def resolve_node(node)
  case node.value
  when Hash
    return resolve_map(node)
  when Array
    return resolve_seq(node)
  when String
    return resolve_scalar(node)
  else
    raise "Don't know how to resolve this node: #{node.inspect}"
  end
end
resolve_scalar(node) click to toggle source
# File lib/safe_yaml/syck_resolver.rb, line 43
def resolve_scalar(node)
  Transform.to_proper_type(node.value, QUOTE_STYLES.include?(node.instance_variable_get(:@style)), node.type_id)
end
resolve_seq(node) click to toggle source
# File lib/safe_yaml/syck_resolver.rb, line 38
def resolve_seq(node)
  seq = node.value
  seq.map { |node| resolve_node(node) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.