aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/renderer/partial_renderer.rb
diff options
context:
space:
mode:
authorEugene Gilburg <eugene.gilburg@gmail.com>2014-07-18 20:54:03 -0700
committerEugene Gilburg <eugene.gilburg@gmail.com>2014-07-18 20:54:03 -0700
commit38117adfe370f0f13503f602cc90ced874428d52 (patch)
tree326ca1b8f94f5bbe2ac5536d5dca82b901ada435 /actionview/lib/action_view/renderer/partial_renderer.rb
parentfe6f436dd9678af8deb4775ff45884489887588f (diff)
downloadrails-38117adfe370f0f13503f602cc90ced874428d52.tar.gz
rails-38117adfe370f0f13503f602cc90ced874428d52.tar.bz2
rails-38117adfe370f0f13503f602cc90ced874428d52.zip
small refactors to actionview renderers
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index a4f6573601..a8d2094f72 100644
--- a/actionview/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
@@ -353,25 +353,27 @@ module ActionView
# respond to +to_partial_path+ in order to setup the path.
def setup(context, options, block)
@view = context
- partial = options[:partial]
-
@options = options
- @locals = options[:locals] || {}
@block = block
+
+ @locals = options[:locals] || {}
@details = extract_details(options)
prepend_formats(options[:formats])
+ partial = options[:partial]
+
if String === partial
@object = options[:object]
+ @collection = collection_from_options
@path = partial
- @collection = collection
else
@object = partial
+ @collection = collection_from_object || collection_from_options
- if @collection = collection_from_object || collection
+ if @collection
paths = @collection_data = @collection.map { |o| partial_path(o) }
- @path = paths.uniq.size == 1 ? paths.first : nil
+ @path = paths.uniq.one? ? paths.first : nil
else
@path = partial_path
end
@@ -392,7 +394,7 @@ module ActionView
self
end
- def collection
+ def collection_from_options
if @options.key?(:collection)
collection = @options[:collection]
collection.respond_to?(:to_ary) ? collection.to_ary : []
@@ -404,9 +406,7 @@ module ActionView
end
def find_partial
- if path = @path
- find_template(path, @template_keys)
- end
+ find_template(@path, @template_keys) if @path
end
def find_template(path, locals)