Class: LogStash::Filters::Dictionary::YamlVisitor

Inherits:
Psych::Visitors::ToRuby
  • Object
show all
Defined in:
lib/logstash/filters/dictionary/yaml_visitor.rb

Constant Summary collapse

TAG_MAP_TABLE =
Hash.new(false)

Instance Method Summary collapse

Instance Method Details

#accept_with_dictionary(dictionary, target) ⇒ Object



18
19
20
21
22
# File 'lib/logstash/filters/dictionary/yaml_visitor.rb', line 18

def accept_with_dictionary(dictionary, target)
  @dictionary = dictionary
  @map_depth = 0
  accept(target)
end

#visit_Psych_Nodes_Mapping(o) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/logstash/filters/dictionary/yaml_visitor.rb', line 24

def visit_Psych_Nodes_Mapping(o)
  if Psych.load_tags[o.tag]
    return revive(resolve_class(Psych.load_tags[o.tag]), o)
  end

  target_hash = @map_depth == 0 ? @dictionary : {}
  @map_depth = @map_depth.succ

  if TAG_MAP_TABLE[o.tag]
    result = revive_hash(register(o, target_hash), o)
  else
    result = super(o)
  end

  @map_depth = @map_depth.pred
  result
end