aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-31 17:26:52 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-02 09:40:23 -0200
commit15206885eb58978465e5f79a4f20cc3c3766de10 (patch)
treeff20547fc0b057550058339b7ace04cab7311bba /actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
parent3312cdb0bbbac2cd43bb8d7bbeca31a4f2cdeaf7 (diff)
downloadrails-15206885eb58978465e5f79a4f20cc3c3766de10.tar.gz
rails-15206885eb58978465e5f79a4f20cc3c3766de10.tar.bz2
rails-15206885eb58978465e5f79a4f20cc3c3766de10.zip
Refactor the methods to use instance variables
[Carlos Antonio da Silva + Rafael Mendonça França]
Diffstat (limited to 'actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb')
-rw-r--r--actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb30
1 files changed, 15 insertions, 15 deletions
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 0b83d3482c..cd02408833 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
+++ b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
@@ -7,31 +7,31 @@ module ActionView
def render
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
+ yield sanitize_attribute_name(value), text, value, default_html_options
else
radio_button(@object_name, @method_name, value, default_html_options) +
- label(@object_name, sanitize_attribute_name(@method_name, value), text, :class => "collection_radio_buttons")
+ label(@object_name, sanitize_attribute_name(value), text, :class => "collection_radio_buttons")
end
end
- wrap_rendered_collection(rendered_collection, @options)
+ wrap_rendered_collection(rendered_collection)
end
private
# Generate default options for collection helpers, such as :checked and
# :disabled.
- def default_html_options_for_collection(item, value, options, html_options) #:nodoc:
- html_options = html_options.dup
+ def default_html_options_for_collection(item, value) #:nodoc:
+ html_options = @html_options.dup
[:checked, :selected, :disabled].each do |option|
- next unless options[option]
+ next unless @options[option]
- accept = if options[option].respond_to?(:call)
- options[option].call(item)
+ accept = if @options[option].respond_to?(:call)
+ @options[option].call(item)
else
- Array(options[option]).include?(value)
+ Array(@options[option]).include?(value)
end
if accept
@@ -44,8 +44,8 @@ module ActionView
html_options
end
- def sanitize_attribute_name(attribute, value) #:nodoc:
- "#{attribute}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase}"
+ def sanitize_attribute_name(value) #:nodoc:
+ "#{sanitized_method_name}_#{value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase}"
end
def render_collection #:nodoc:
@@ -55,7 +55,7 @@ module ActionView
@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)
+ default_html_options = default_html_options_for_collection(item, value)
rendered_item = yield value, text, default_html_options
@@ -67,11 +67,11 @@ module ActionView
value.respond_to?(:call) ? value.call(item) : item.send(value)
end
- def wrap_rendered_collection(collection, options)
- wrapper_tag = options[:collection_wrapper_tag]
+ def wrap_rendered_collection(collection)
+ wrapper_tag = @options[:collection_wrapper_tag]
if wrapper_tag
- wrapper_class = options[:collection_wrapper_class]
+ wrapper_class = @options[:collection_wrapper_class]
@template_object.content_tag(wrapper_tag, collection, :class => wrapper_class)
else
collection