class RuboCop::Cop::Legacy::CorrectionsProxy

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

Attributes

corrector[R]

Public Class Methods

new(corrector) click to toggle source
# File lib/rubocop/cop/legacy/corrections_proxy.rb, line 9
def initialize(corrector)
  @corrector = corrector
end

Public Instance Methods

<<(callable) click to toggle source
# File lib/rubocop/cop/legacy/corrections_proxy.rb, line 13
def <<(callable)
  suppress_clobbering { @corrector.transaction { callable.call(@corrector) } }
end
concat(corrections) click to toggle source
# File lib/rubocop/cop/legacy/corrections_proxy.rb, line 21
def concat(corrections)
  if corrections.is_a?(CorrectionsProxy)
    suppress_clobbering { corrector.merge!(corrections.corrector) }
  else
    corrections.each { |correction| self << correction }
  end
end
empty?() click to toggle source
# File lib/rubocop/cop/legacy/corrections_proxy.rb, line 17
def empty?
  @corrector.empty?
end

Private Instance Methods

suppress_clobbering() { || ... } click to toggle source
# File lib/rubocop/cop/legacy/corrections_proxy.rb, line 35
def suppress_clobbering
  yield
rescue ::Parser::ClobberingError
  # ignore Clobbering errors
end