Class: SelectableAttrRails::Helpers::RadioButtonGroupHelper::Builder
- Inherits:
-
AbstractSelectionBuilder
- Object
- AbstractSelectionBuilder
- SelectableAttrRails::Helpers::RadioButtonGroupHelper::Builder
- Defined in:
- lib/selectable_attr_rails/helpers/radio_button_group_helper.rb
Instance Attribute Summary collapse
-
#entry_hash ⇒ Object
readonly
Returns the value of attribute entry_hash.
-
#entry_hash_array ⇒ Object
readonly
Returns the value of attribute entry_hash_array.
-
#radio_button_id ⇒ Object
Returns the value of attribute radio_button_id.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(object, object_name, method, options, template) ⇒ Builder
constructor
A new instance of Builder.
- #label(text = nil, options = nil) ⇒ Object
- #radio_button(options = nil) ⇒ Object
Methods inherited from AbstractSelectionBuilder
#add_class_name, #camelize_keys, #enum_hash_array_from_class, #enum_hash_array_from_object, #tag_id, #update_options
Constructor Details
#initialize(object, object_name, method, options, template) ⇒ Builder
Returns a new instance of Builder.
9 10 11 12 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 9 def initialize(object, object_name, method, , template) super(object, object_name, method, , template) @entry_hash_array ||= enum_hash_array_from_class end |
Instance Attribute Details
#entry_hash ⇒ Object (readonly)
Returns the value of attribute entry_hash.
6 7 8 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 6 def entry_hash @entry_hash end |
#entry_hash_array ⇒ Object (readonly)
Returns the value of attribute entry_hash_array.
5 6 7 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 5 def entry_hash_array @entry_hash_array end |
#radio_button_id ⇒ Object
Returns the value of attribute radio_button_id.
7 8 9 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 7 def @radio_button_id end |
Instance Method Details
#each(&block) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 14 def each(&block) @entry_hash_array.each do |entry_hash| @entry_hash = entry_hash tag_value = @entry_hash[:id].to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase @radio_button_id = "#{@object_name}_#{@method}_#{tag_value}" yield(self) end end |
#label(text = nil, options = nil) ⇒ Object
28 29 30 31 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 28 def label(text = nil, = nil) @template.content_tag("label", text || @entry_hash[:name], ({:for => @radio_button_id}, )) end |
#radio_button(options = nil) ⇒ Object
23 24 25 26 |
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 23 def ( = nil) @template.(@object_name, @method, @entry_hash[:id], ({:id => @radio_button_id}, )) end |