diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-01-31 16:55:44 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-02-02 09:40:22 -0200 |
commit | 1e632a7df6ade9ec584a8d4517d0df9f4b0d9951 (patch) | |
tree | c625ccac6f5e4e17b3ff39248da8c5a0be9d718b | |
parent | 5c497262f3d0a1d3f754506894efca051162846d (diff) | |
download | rails-1e632a7df6ade9ec584a8d4517d0df9f4b0d9951.tar.gz rails-1e632a7df6ade9ec584a8d4517d0df9f4b0d9951.tar.bz2 rails-1e632a7df6ade9ec584a8d4517d0df9f4b0d9951.zip |
Refactor render_collection method
[Carlos Antonio da Silva + Rafael Mendonça França]
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb | 18 |
2 files changed, 9 insertions, 13 deletions
diff --git a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb index d8f7a1fff6..ae27c4e6da 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -5,9 +5,7 @@ module ActionView delegate :check_box, :label, :to => :@template_object def render - rendered_collection = render_collection( - @method_name, @collection, @value_method, @text_method, @options, @html_options - ) do |value, text, default_html_options| + rendered_collection = render_collection do |value, text, default_html_options| default_html_options[:multiple] = true if block_given? diff --git a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb index eea8c41dc0..0b83d3482c 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -5,9 +5,7 @@ module ActionView delegate :radio_button, :label, :to => :@template_object def render - rendered_collection = render_collection( - @method_name, @collection, @value_method, @text_method, @options, @html_options - ) do |value, text, default_html_options| + rendered_collection = render_collection do |value, text, default_html_options| if block_given? yield sanitize_attribute_name(@method_name, value), text, value, default_html_options else @@ -50,14 +48,14 @@ module ActionView "#{attribute}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase}" end - def render_collection(attribute, collection, value_method, text_method, options={}, html_options={}) #:nodoc: - item_wrapper_tag = options.fetch(:item_wrapper_tag, :span) - item_wrapper_class = options[:item_wrapper_class] + def render_collection #:nodoc: + item_wrapper_tag = @options.fetch(:item_wrapper_tag, :span) + item_wrapper_class = @options[:item_wrapper_class] - collection.map do |item| - value = value_for_collection(item, value_method) - text = value_for_collection(item, text_method) - default_html_options = default_html_options_for_collection(item, value, options, html_options) + @collection.map do |item| + value = value_for_collection(item, @value_method) + text = value_for_collection(item, @text_method) + default_html_options = default_html_options_for_collection(item, value, @options, @html_options) rendered_item = yield value, text, default_html_options |