mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Support both the _render_option_json and the newer _render_with_renderer_json methods
This commit is contained in:
parent
66d39b6c0a
commit
18667712ea
@ -33,19 +33,22 @@ module ActionController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def serialization_scope
|
def serialization_scope
|
||||||
send(_serialization_scope) if _serialization_scope && respond_to?(_serialization_scope, true)
|
send(_serialization_scope) if _serialization_scope &&
|
||||||
|
respond_to?(_serialization_scope, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_serializer_options
|
def default_serializer_options
|
||||||
end
|
end
|
||||||
|
|
||||||
def _render_option_json(resource, options)
|
%i(_render_option_json _render_with_renderer_json).each do |renderer_method|
|
||||||
json = ActiveModel::Serializer.build_json(self, resource, options)
|
define_method renderer_method do |resource, options|
|
||||||
|
json = ActiveModel::Serializer.build_json(self, resource, options)
|
||||||
|
|
||||||
if json
|
if json
|
||||||
super(json, options)
|
super(json, options)
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user