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