Class: RuboCop::Cop::Rails::DestroyAllBang

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/rails/destroy_all_bang.rb

Overview

Constant Summary collapse

MSG =
'Use `each(&:destroy!)` instead of `destroy_all`.'
RESTRICT_ON_SEND =
i[destroy_all].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



21
22
23
24
25
26
# File 'lib/rubocop/cop/rails/destroy_all_bang.rb', line 21

def on_send(node)
  destroy_all_range = node.loc.selector
  add_offense(destroy_all_range) do |corrector|
    corrector.replace(node.loc.selector, 'each(&:destroy!)')
  end
end