Class: RuboCop::Cop::Legacy::CorrectionsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/legacy/corrections_proxy.rb

Overview

Legacy support for Corrector#corrections See docs.rubocop.org/rubocop/cop_api_v1_changelog.html

Instance Method Summary collapse

Constructor Details

#initialize(corrector) ⇒ CorrectionsProxy

Returns a new instance of CorrectionsProxy.


9
10
11
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 9

def initialize(corrector)
  @corrector = corrector
end

Instance Method Details

#<<(callable) ⇒ Object


13
14
15
16
17
18
19
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 13

def <<(callable)
  suppress_clobbering do
    @corrector.transaction do
      callable.call(@corrector)
    end
  end
end

#concat(corrections) ⇒ Object


25
26
27
28
29
30
31
32
33
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 25

def concat(corrections)
  if corrections.is_a?(CorrectionsProxy)
    suppress_clobbering do
      corrector.merge!(corrections.corrector)
    end
  else
    corrections.each { |correction| self << correction }
  end
end

#empty?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 21

def empty?
  @corrector.empty?
end