Class: RuboCop::Cop::Rails::PostgresqlCursor

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/rails/postgresql_cursor.rb

Constant Summary collapse

MSG =
'Prefer `each_instance` over `find_each`.'

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



14
15
16
17
18
# File 'lib/rubocop/cop/rails/postgresql_cursor.rb', line 14

def autocorrect(node)
  @corrections << lambda do |corrector|
    corrector.replace(node.loc.selector, 'each_instance')
  end
end

#on_send(node) ⇒ Object



7
8
9
10
11
12
# File 'lib/rubocop/cop/rails/postgresql_cursor.rb', line 7

def on_send(node)
  _receiver, method_name, *_args = *node
  return unless :find_each == method_name

  add_offense(node, :selector, MSG)
end