Class: RuboCop::YAMLDuplicationChecker::DuplicationCheckHandler Private
- Inherits:
-
Psych::TreeBuilder
- Object
- Psych::TreeBuilder
- RuboCop::YAMLDuplicationChecker::DuplicationCheckHandler
- Defined in:
- lib/rubocop/yaml_duplication_checker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
:nodoc:
Instance Method Summary collapse
- #end_mapping ⇒ Object private
-
#initialize(&block) ⇒ DuplicationCheckHandler
constructor
private
A new instance of DuplicationCheckHandler.
Constructor Details
#initialize(&block) ⇒ DuplicationCheckHandler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DuplicationCheckHandler.
15 16 17 18 |
# File 'lib/rubocop/yaml_duplication_checker.rb', line 15 def initialize(&block) super() @block = block end |
Instance Method Details
#end_mapping ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |