Make rubocop happy.
This commit is contained in:
parent
c5eb1ce27c
commit
ef93f7f358
21
.rubocop.yml
21
.rubocop.yml
@ -2,6 +2,10 @@ require:
|
|||||||
- rubocop-performance
|
- rubocop-performance
|
||||||
- rubocop-rspec
|
- rubocop-rspec
|
||||||
|
|
||||||
|
AllCops:
|
||||||
|
NewCops: enable
|
||||||
|
SuggestExtensions: false
|
||||||
|
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
@ -76,3 +80,20 @@ Naming/PredicateName:
|
|||||||
Naming/AccessorMethodName:
|
Naming/AccessorMethodName:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/**/**.rb'
|
- 'lib/**/**.rb'
|
||||||
|
|
||||||
|
Style/CaseLikeIf:
|
||||||
|
Exclude:
|
||||||
|
- 'lib/fast_jsonapi/object_serializer.rb'
|
||||||
|
|
||||||
|
Style/OptionalBooleanParameter:
|
||||||
|
Exclude:
|
||||||
|
- 'lib/fast_jsonapi/serialization_core.rb'
|
||||||
|
- 'lib/fast_jsonapi/relationship.rb'
|
||||||
|
|
||||||
|
Lint/DuplicateBranch:
|
||||||
|
Exclude:
|
||||||
|
- 'lib/fast_jsonapi/relationship.rb'
|
||||||
|
|
||||||
|
Style/DocumentDynamicEvalDefinition:
|
||||||
|
Exclude:
|
||||||
|
- 'lib/extensions/has_one.rb'
|
||||||
|
@ -228,10 +228,10 @@ module FastJsonapi
|
|||||||
|
|
||||||
# TODO: Remove this undocumented option.
|
# TODO: Remove this undocumented option.
|
||||||
# Delegate the caching to the serializer exclusively.
|
# Delegate the caching to the serializer exclusively.
|
||||||
if !relationship.cached
|
if relationship.cached
|
||||||
uncachable_relationships_to_serialize[relationship.name] = relationship
|
|
||||||
else
|
|
||||||
cachable_relationships_to_serialize[relationship.name] = relationship
|
cachable_relationships_to_serialize[relationship.name] = relationship
|
||||||
|
else
|
||||||
|
uncachable_relationships_to_serialize[relationship.name] = relationship
|
||||||
end
|
end
|
||||||
relationships_to_serialize[relationship.name] = relationship
|
relationships_to_serialize[relationship.name] = relationship
|
||||||
end
|
end
|
||||||
@ -302,7 +302,7 @@ module FastJsonapi
|
|||||||
|
|
||||||
def serializer_for(name)
|
def serializer_for(name)
|
||||||
namespace = self.name.gsub(/()?\w+Serializer$/, '')
|
namespace = self.name.gsub(/()?\w+Serializer$/, '')
|
||||||
serializer_name = name.to_s.demodulize.classify + 'Serializer'
|
serializer_name = "#{name.to_s.demodulize.classify}Serializer"
|
||||||
serializer_class_name = namespace + serializer_name
|
serializer_class_name = namespace + serializer_name
|
||||||
begin
|
begin
|
||||||
serializer_class_name.constantize
|
serializer_class_name.constantize
|
||||||
@ -340,7 +340,7 @@ module FastJsonapi
|
|||||||
def validate_includes!(includes)
|
def validate_includes!(includes)
|
||||||
return if includes.blank?
|
return if includes.blank?
|
||||||
|
|
||||||
parse_includes_list(includes).keys.each do |include_item|
|
parse_includes_list(includes).each_key do |include_item|
|
||||||
relationship_to_include = relationships_to_serialize[include_item]
|
relationship_to_include = relationships_to_serialize[include_item]
|
||||||
raise(JSONAPI::Serializer::UnsupportedIncludeError.new(include_item, name)) unless relationship_to_include
|
raise(JSONAPI::Serializer::UnsupportedIncludeError.new(include_item, name)) unless relationship_to_include
|
||||||
|
|
||||||
|
@ -12,7 +12,12 @@ module FastJsonapi
|
|||||||
object_block:,
|
object_block:,
|
||||||
serializer:,
|
serializer:,
|
||||||
relationship_type:,
|
relationship_type:,
|
||||||
polymorphic:, conditional_proc:, transform_method:, links:, meta:, cached: false,
|
polymorphic:,
|
||||||
|
conditional_proc:,
|
||||||
|
transform_method:,
|
||||||
|
links:,
|
||||||
|
meta:,
|
||||||
|
cached: false,
|
||||||
lazy_load_data: false
|
lazy_load_data: false
|
||||||
)
|
)
|
||||||
@owner = owner
|
@owner = owner
|
||||||
|
@ -8,6 +8,7 @@ module JSONAPI
|
|||||||
attr_reader :include_item, :klass
|
attr_reader :include_item, :klass
|
||||||
|
|
||||||
def initialize(include_item, klass)
|
def initialize(include_item, klass)
|
||||||
|
super()
|
||||||
@include_item = include_item
|
@include_item = include_item
|
||||||
@klass = klass
|
@klass = klass
|
||||||
end
|
end
|
||||||
|
2
spec/fixtures/movie.rb
vendored
2
spec/fixtures/movie.rb
vendored
@ -26,7 +26,7 @@ class Movie
|
|||||||
@url ||= FFaker::Internet.http_url
|
@url ||= FFaker::Internet.http_url
|
||||||
return @url if obj.nil?
|
return @url if obj.nil?
|
||||||
|
|
||||||
@url + '?' + obj.hash.to_s
|
"#{@url}?#{obj.hash}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def owner=(ownr)
|
def owner=(ownr)
|
||||||
|
@ -10,10 +10,8 @@ RSpec.describe JSONAPI::Serializer do
|
|||||||
|
|
||||||
it do
|
it do
|
||||||
payload = event_name = nil
|
payload = event_name = nil
|
||||||
notification_name = (
|
notification_name =
|
||||||
::JSONAPI::Serializer::Instrumentation::NOTIFICATION_NAMESPACE +
|
"#{::JSONAPI::Serializer::Instrumentation::NOTIFICATION_NAMESPACE}serializable_hash"
|
||||||
'serializable_hash'
|
|
||||||
)
|
|
||||||
|
|
||||||
ActiveSupport::Notifications.subscribe(
|
ActiveSupport::Notifications.subscribe(
|
||||||
notification_name
|
notification_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user