Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor render_collection method

[Carlos Antonio da Silva + Rafael Mendonça França]
  • Loading branch information...
commit 1e632a7df6ade9ec584a8d4517d0df9f4b0d9951 1 parent 5c49726
@rafaelfranca rafaelfranca authored carlosantoniodasilva committed
View
4 actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb
@@ -5,9 +5,7 @@ class CollectionCheckBoxes < CollectionRadioButtons
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?
View
18 actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
@@ -5,9 +5,7 @@ class CollectionRadioButtons < CollectionSelect
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 @@ def sanitize_attribute_name(attribute, value) #:nodoc:
"#{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
Please sign in to comment.
Something went wrong with that request. Please try again.