123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::YAMLDuplicationChecker::DuplicationCheckHandler Private

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Psych::TreeBuilder
Instance Chain:
self, Psych::TreeBuilder
Inherits: Psych::TreeBuilder
  • Object
Defined in: lib/rubocop/yaml_duplication_checker.rb

Overview

Class Method Summary

Instance Method Summary

Constructor Details

.new(&block) ⇒ DuplicationCheckHandler

[ GitHub ]

  
# File 'lib/rubocop/yaml_duplication_checker.rb', line 15

def initialize(&block)
  super()
  @block = block
end

Instance Method Details

#end_mapping

[ GitHub ]

  
# File 'lib/rubocop/yaml_duplication_checker.rb', line 20

def end_mapping
  mapping_node = super
  # OPTIMIZE: Use a hash for faster lookup since there can
  # be quite a few keys at the top-level.
  keys = {}
  mapping_node.children.each_slice(2) do |key, _value|
    duplicate = keys[key.value]
    @block.call(duplicate, key) if duplicate
    keys[key.value] = key
  end
  mapping_node
end