123456789_123456789_123456789_123456789_123456789_

Class: Psych::Visitors::YAMLTree::Registrar

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: ext/psych/lib/psych/visitors/yaml_tree.rb

Class Method Summary

Instance Method Summary

Constructor Details

.newRegistrar

[ GitHub ]

  
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 17

def initialize
  @obj_to_id   = {}.compare_by_identity
  @obj_to_node = {}.compare_by_identity
  @targets     = []
  @counter     = 0
end

Instance Method Details

#id_for(target)

[ GitHub ]

  
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 35

def id_for target
  @obj_to_id[target] ||= (@counter += 1)
end

#key?(target) ⇒ Boolean

[ GitHub ]

  
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 29

def key? target
  @obj_to_node.key? target
rescue NoMethodError
  false
end

#node_for(target)

[ GitHub ]

  
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 39

def node_for target
  @obj_to_node[target]
end

#register(target, node)

[ GitHub ]

  
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 24

def register target, node
  @targets << target
  @obj_to_node[target] = node
end