mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Improve build_json_serializer readability a bit
This commit is contained in:
parent
4d4b820cbe
commit
616938dc63
@ -64,11 +64,7 @@ module ActionController
|
|||||||
def build_json_serializer(resource, options)
|
def build_json_serializer(resource, options)
|
||||||
options = default_serializer_options.merge(options || {})
|
options = default_serializer_options.merge(options || {})
|
||||||
|
|
||||||
serializer = options.delete(:serializer)
|
if serializer = options.fetch(:serializer, ActiveModel::Serializer.serializer_for(resource))
|
||||||
serializer = ActiveModel::Serializer.serializer_for(resource) if serializer.nil?
|
|
||||||
|
|
||||||
return unless serializer
|
|
||||||
|
|
||||||
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
||||||
options[:resource_name] = self.controller_name if resource.respond_to?(:to_ary)
|
options[:resource_name] = self.controller_name if resource.respond_to?(:to_ary)
|
||||||
|
|
||||||
@ -76,3 +72,4 @@ module ActionController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user