diff options
Diffstat (limited to 'actionpack/lib/action_controller/new_base/render_options.rb')
-rw-r--r-- | actionpack/lib/action_controller/new_base/render_options.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/new_base/render_options.rb b/actionpack/lib/action_controller/new_base/render_options.rb index e7ed2bd278..a9ac0e0a41 100644 --- a/actionpack/lib/action_controller/new_base/render_options.rb +++ b/actionpack/lib/action_controller/new_base/render_options.rb @@ -18,15 +18,23 @@ module ActionController end end - module Renderers - module Json + module RenderOption + extend ActiveSupport::DependencyModule + + included do extend ActiveSupport::DependencyModule - depends_on RenderOptions - - included do - _renderers << :json + + def self.register_renderer(name) + included { _renderers << name } end + end + end + + module Renderers + module Json + include RenderOption + register_renderer :json def _render_json(json, options) json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str) @@ -35,5 +43,15 @@ module ActionController self.response_body = json end end + + module Xml + include RenderOption + register_renderer :xml + + def _render_xml(xml, options) + response.content_type ||= Mime::XML + self.response_body = xml.respond_to?(:to_xml) ? xml.to_xml : xml + end + end end end
\ No newline at end of file |