Parent

SafeYAML::PsychHandler

Public Class Methods

new() click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 6
def initialize
  @anchors = {}
  @stack = []
  @current_key = nil
  @result = nil
end

Public Instance Methods

add_to_current_structure(value, anchor=nil, quoted=nil, tag=nil) click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 17
def add_to_current_structure(value, anchor=nil, quoted=nil, tag=nil)
  value = Transform.to_proper_type(value, quoted, tag)

  @anchors[anchor] = value if anchor

  if @result.nil?
    @result = value
    @current_structure = @result
    return
  end

  case @current_structure
  when Array
    @current_structure.push(value)

  when Hash
    if @current_key.nil?
      @current_key = value

    else
      if @current_key == "<<"
        @current_structure.merge!(value)
      else
        @current_structure[@current_key] = value
      end

      @current_key = nil
    end

  else
    raise "Don't know how to add to a #{@current_structure.class}!"
  end
end
alias(anchor) click to toggle source

event handlers

# File lib/safe_yaml/psych_handler.rb, line 61
def alias(anchor)
  add_to_current_structure(@anchors[anchor])
end
end_current_structure() click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 51
def end_current_structure
  @stack.pop
  @current_structure = @stack.last
end
end_mapping() click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 76
def end_mapping
  self.end_current_structure()
end
end_sequence() click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 87
def end_sequence
  self.end_current_structure()
end
result() click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 13
def result
  @result
end
scalar(value, anchor, tag, plain, quoted, style) click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 65
def scalar(value, anchor, tag, plain, quoted, style)
  add_to_current_structure(value, anchor, quoted, tag)
end
start_mapping(anchor, tag, implicit, style) click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 69
def start_mapping(anchor, tag, implicit, style)
  map = {}
  self.add_to_current_structure(map, anchor)
  @current_structure = map
  @stack.push(map)
end
start_sequence(anchor, tag, implicit, style) click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 80
def start_sequence(anchor, tag, implicit, style)
  seq = []
  self.add_to_current_structure(seq, anchor)
  @current_structure = seq
  @stack.push(seq)
end
streaming?() click to toggle source
# File lib/safe_yaml/psych_handler.rb, line 56
def streaming?
  false
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.