123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Inherits: Object
Defined in: lib/rubocop/cop/legacy/corrections_proxy.rb

Overview

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(corrector) ⇒ CorrectionsProxy

[ GitHub ]

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

def initialize(corrector)
  @corrector = corrector
end

Instance Attribute Details

#empty?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 17

def empty?
  @corrector.empty?
end

Instance Method Details

#<<(callable)

[ GitHub ]

  
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 13

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

#concat(corrections)

[ GitHub ]

  
# 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

#suppress_clobbering (private)

[ GitHub ]

  
# File 'lib/rubocop/cop/legacy/corrections_proxy.rb', line 35

def suppress_clobbering
  yield
rescue ::Parser::ClobberingError
  # ignore Clobbering errors
end