Support both the _render_option_json and the newer _render_with_renderer_json methods

This commit is contained in:
Wouter Willaert 2014-09-18 18:23:39 +02:00
parent 66d39b6c0a
commit 18667712ea

View File

@ -33,19 +33,22 @@ module ActionController
end
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
def default_serializer_options
end
def _render_option_json(resource, options)
json = ActiveModel::Serializer.build_json(self, resource, options)
%i(_render_option_json _render_with_renderer_json).each do |renderer_method|
define_method renderer_method do |resource, options|
json = ActiveModel::Serializer.build_json(self, resource, options)
if json
super(json, options)
else
super
if json
super(json, options)
else
super
end
end
end