Class: SelectableAttrRails::Helpers::CheckBoxGroupHelper::Builder
Instance Attribute Summary
#entry_hash
Instance Method Summary
collapse
#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.
6
7
8
9
10
11
|
# File 'lib/selectable_attr_rails/helpers/check_box_group_helper.rb', line 6
def initialize(object, object_name, method, options, template)
super(object, object_name, method, options, template)
@entry_hash_array ||= enum_hash_array_from_object
@param_name = "#{@base_name}_ids"
@check_box_options = @options.delete(:check_box) || {}
end
|
Instance Method Details
#check_box(options = nil) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/selectable_attr_rails/helpers/check_box_group_helper.rb', line 21
def check_box(options = nil)
options = update_options({
:id => @check_box_id, :type => 'checkbox', :value => @tag_value,
:name => "#{@object_name}[#{@param_name}][]"
}, @check_box_options, options)
options[:checked] = 'checked' if @entry_hash[:select]
@template.content_tag("input", nil, options)
end
|
#each(&block) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/selectable_attr_rails/helpers/check_box_group_helper.rb', line 13
def each(&block)
@entry_hash_array.each do |@entry_hash|
@tag_value = @entry_hash[:id].to_s.gsub(/\s/, "_").gsub(/\W/, "")
@check_box_id = "#{@object_name}_#{@param_name}_#{@tag_value}"
yield(self)
end
end
|
#label(text = nil, options = nil) ⇒ Object
30
31
32
33
|
# File 'lib/selectable_attr_rails/helpers/check_box_group_helper.rb', line 30
def label(text = nil, options = nil)
@template.content_tag("label", text || @entry_hash[:name],
update_options({:for => @check_box_id}, options))
end
|