diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-19 14:22:00 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-19 14:22:00 -0300 |
commit | e89ef3cee9a38f69634e8e7d55dc69841b06e55d (patch) | |
tree | 67551670acaefa85ad913150ab4d23ea84fe9c12 /actionview/lib/action_view/renderer/partial_renderer.rb | |
parent | 433c52864a703312497d5f07c01a17e6fbc769aa (diff) | |
parent | 080c2ba0cadc9789ae97a35ef23808d3c0197b9c (diff) | |
download | rails-e89ef3cee9a38f69634e8e7d55dc69841b06e55d.tar.gz rails-e89ef3cee9a38f69634e8e7d55dc69841b06e55d.tar.bz2 rails-e89ef3cee9a38f69634e8e7d55dc69841b06e55d.zip |
Merge pull request #16224 from egilburg/renderer_refactors
Some ActionView renderer refactors
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer.rb | 22 |
1 files changed, 12 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..0407632435 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -312,6 +312,8 @@ module ActionView end end + private + def render_collection return nil if @collection.blank? @@ -353,25 +355,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 +396,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 +408,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) |