aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-03-08 03:23:16 +0100
committerJosé Valim <jose.valim@gmail.com>2010-03-08 03:23:23 +0100
commit34b2180451f842b180dd925bab10e8f4afa34490 (patch)
treefd364e4ee5944c6bb99c1badc97caa815e8eae1e /actionpack/lib
parent4bae77a89baf0fee15c6b2cfd3987f7344b56a1f (diff)
downloadrails-34b2180451f842b180dd925bab10e8f4afa34490.tar.gz
rails-34b2180451f842b180dd925bab10e8f4afa34490.tar.bz2
rails-34b2180451f842b180dd925bab10e8f4afa34490.zip
More refactoring. Split _normalize_args and _normalize_options concerns.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/abstract_controller/layouts.rb8
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb12
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb19
3 files changed, 27 insertions, 12 deletions
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb
index c6a94c5220..648a2da795 100644
--- a/actionpack/lib/abstract_controller/layouts.rb
+++ b/actionpack/lib/abstract_controller/layouts.rb
@@ -277,8 +277,8 @@ module AbstractController
end
end
- def render_to_body(options={})
- if (options.keys & [:text, :inline, :partial]).empty? || options.key?(:layout)
+ def render_to_body(options)
+ if _include_layout?(options)
layout = options.key?(:layout) ? options[:layout] : :default
value = _layout_for_option(layout)
@@ -344,6 +344,10 @@ module AbstractController
layout_name
end
+ def _include_layout?(options)
+ (options.keys & [:text, :inline, :partial]).empty? || options.key?(:layout)
+ end
+
def _action_has_layout?
true
end
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 8125badc75..9093e90c97 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -45,7 +45,8 @@ module AbstractController
# Mostly abstracts the fact that calling render twice is a DoubleRenderError.
# Delegates render_to_body and sticks the result in self.response_body.
def render(*args, &block)
- options = _normalize_options(*args, &block)
+ options = _normalize_args(*args, &block)
+ _normalize_options(options)
self.response_body = render_to_body(options)
end
@@ -70,8 +71,8 @@ module AbstractController
# render_to_body into a String.
#
# :api: plugin
- def render_to_string(*args)
- options = _normalize_options(*args)
+ def render_to_string(options={})
+ _normalize_options(options)
AbstractController::Rendering.body_to_s(render_to_body(options))
end
@@ -131,7 +132,7 @@ module AbstractController
# Normalize options, by converting render "foo" to render :template => "prefix/foo"
# and render "/foo" to render :file => "/foo".
- def _normalize_options(action=nil, options={})
+ def _normalize_args(action=nil, options={})
case action
when Hash
options, action = action, nil
@@ -151,6 +152,9 @@ module AbstractController
options
end
+ def _normalize_options(options)
+ end
+
# Take in a set of options and determine the template to render
#
# ==== Options
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index e2d2e2312b..60d61999de 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -18,6 +18,11 @@ module ActionController
response_body
end
+ def render_to_body(options)
+ _process_options(options)
+ super
+ end
+
private
def _render_partial(options)
@@ -30,7 +35,7 @@ module ActionController
formats.first
end
- def _normalize_options(action=nil, options={}, &blk)
+ def _normalize_args(action=nil, options={}, &blk)
case action
when NilClass
when Hash
@@ -38,9 +43,14 @@ module ActionController
when String, Symbol
options = super
else
- options.merge! :partial => action
+ options.merge!(:partial => action)
end
+ options[:update] = blk if block_given?
+ options
+ end
+
+ def _normalize_options(options)
if options.key?(:text) && options[:text].respond_to?(:to_text)
options[:text] = options[:text].to_text
end
@@ -49,10 +59,7 @@ module ActionController
options[:status] = Rack::Utils.status_code(options[:status])
end
- options[:update] = blk if block_given?
-
- _process_options(options)
- options
+ super
end
def _process_options(options)