From a2ca04bb3ac178bbe1503ac65dc88f5f3f8cb37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Sun, 11 Aug 2013 23:19:22 +0200 Subject: Extend basic rendering, test it in railties --- actionpack/lib/action_controller/metal/rendering.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/metal') diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 2d58e1440c..d965cb8c16 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -6,15 +6,28 @@ module ActionController # :api: public def render(*args, &block) super(*args, &block) - text = args.first[:text] - if text.present? - self.response_body = text + opts = args.first + if (opts.keys & [:text, :nothing]).present? + self.response_body = if opts.has_key?(:text) && opts[:text].present? + opts[:text] + elsif opts.has_key?(:nothing) && opts[:nothing] + " " + end + else + raise UnsupportedOperationError end end def rendered_format Mime::TEXT end + + class UnsupportedOperationError < StandardError + def initialize + super "Unsupported render operation. BasicRendering supports only :text + and :nothing options. For more, you need to include ActionView." + end + end end module Rendering -- cgit v1.2.3