blob: e7ed2bd278fd39843c953451dad3993871e14850 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
module ActionController
module RenderOptions
extend ActiveSupport::DependencyModule
included do
extlib_inheritable_accessor :_renderers
self._renderers = []
end
def render_to_body(options)
_renderers.each do |renderer|
if options.key?(renderer)
_process_options(options)
return send("_render_#{renderer}", options[renderer], options)
end
end
super
end
end
module Renderers
module Json
extend ActiveSupport::DependencyModule
depends_on RenderOptions
included do
_renderers << :json
end
def _render_json(json, options)
json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
response.content_type ||= Mime::JSON
self.response_body = json
end
end
end
end
|