Class: RuboCop::Cop::Salsify::RailsApplicationSerializer

Inherits:
RuboCop::Cop
  • Object
show all
Extended by:
TargetRailsVersion
Includes:
EnforceSuperclass
Defined in:
lib/rubocop/cop/salsify/rails_application_serializer.rb

Overview

Check that serializers subclass ApplicationSerializer with Rails 5.0.

Examples:


# good
class Tesla < ApplicationSerializer
  ...
end

# bad
class Yugo < ActiveModel::Serializer
  ...
end

Constant Summary collapse

MSG =
'Serializers should subclass `ApplicationSerializer`.'
SUPERCLASS =
'ApplicationSerializer'
BASE_PATTERN =
'(const (const nil? :ActiveModel) :Serializer)'

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object


30
31
32
33
34
# File 'lib/rubocop/cop/salsify/rails_application_serializer.rb', line 30

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.source_range, self.class::SUPERCLASS)
  end
end