mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Make it possible to supply default serializer
options in a controller.
This commit is contained in:
@@ -36,6 +36,9 @@ module ActionController
|
||||
send(_serialization_scope)
|
||||
end
|
||||
|
||||
def default_serializer_options
|
||||
end
|
||||
|
||||
def _render_option_json(json, options)
|
||||
if json.respond_to?(:to_ary)
|
||||
options[:root] ||= controller_name
|
||||
@@ -43,6 +46,11 @@ module ActionController
|
||||
|
||||
if json.respond_to?(:active_model_serializer) && (serializer = json.active_model_serializer)
|
||||
options[:scope] = serialization_scope
|
||||
|
||||
if default_options = default_serializer_options
|
||||
options = options.merge(default_options)
|
||||
end
|
||||
|
||||
json = serializer.new(json, options)
|
||||
end
|
||||
super
|
||||
|
||||
Reference in New Issue
Block a user