diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-20 14:21:27 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-20 15:02:13 +0100 |
commit | 8e2fd54b19656a6edbd94f8707927d09e167e7fc (patch) | |
tree | c000b4aa817f677d8160a13e630a2536e76264d0 /actionpack/lib/action_controller | |
parent | 8b9bfbe225a59ccefa46f1e8bf301bc483bef0e0 (diff) | |
download | rails-8e2fd54b19656a6edbd94f8707927d09e167e7fc.tar.gz rails-8e2fd54b19656a6edbd94f8707927d09e167e7fc.tar.bz2 rails-8e2fd54b19656a6edbd94f8707927d09e167e7fc.zip |
Bring normalize behavior to AbstractController::Rendering
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 29 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/instrumentation.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/rendering.rb | 7 |
3 files changed, 17 insertions, 35 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index f86a61d791..4f928e37ea 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -74,17 +74,14 @@ module ActionController @subclasses ||= [] end - def _normalize_options(action = nil, options = {}, &blk) - if action.is_a?(Hash) - options, action = action, nil - elsif action.is_a?(String) || action.is_a?(Symbol) - key = case action = action.to_s - when %r{^/} then :file - when %r{/} then :template - else :action - end - options.merge! key => action - elsif action + def _normalize_options(action=nil, options={}, &blk) + case action + when NilClass + when Hash, String + options = super + when Symbol + options.merge! :action => action + else options.merge! :partial => action end @@ -99,15 +96,5 @@ module ActionController options[:update] = blk if block_given? options end - - def render(action = nil, options = {}, &blk) - options = _normalize_options(action, options, &blk) - super(options) - end - - def render_to_string(action = nil, options = {}, &blk) - options = _normalize_options(action, options, &blk) - super(options) - end end end diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb index 7b2b037c67..19c962bafa 100644 --- a/actionpack/lib/action_controller/metal/instrumentation.rb +++ b/actionpack/lib/action_controller/metal/instrumentation.rb @@ -32,18 +32,12 @@ module ActionController end end - def render(*args, &block) - if logger - render_output = nil - - self.view_runtime = cleanup_view_runtime do - Benchmark.ms { render_output = super } - end - - render_output - else - super + def render(*args) + render_output = nil + self.view_runtime = cleanup_view_runtime do + Benchmark.ms { render_output = super } end + render_output end def send_file(path, options={}) diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 74e50bb032..475ed54167 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -12,9 +12,10 @@ module ActionController super end - def render(options) - super - self.content_type ||= options[:_template].mime_type.to_s + def render(*args) + args << {} unless args.last.is_a?(Hash) + super(*args) + self.content_type ||= args.last[:_template].mime_type.to_s response_body end |