Class: TaoForm::Components::RadioButtonComponent

Inherits:
FieldComponent
  • Object
show all
Defined in:
lib/tao_form/components/radio_button_component.rb

Instance Attribute Summary collapse

Attributes inherited from FieldComponent

#attribute_name, #builder

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, builder = nil, attribute_name = nil, options = {}, checked_value = '1', unchecked_value = '0') ⇒ RadioButtonComponent

Returns a new instance of RadioButtonComponent.



7
8
9
10
11
# File 'lib/tao_form/components/radio_button_component.rb', line 7

def initialize view, builder = nil, attribute_name = nil, options = {}, checked_value = '1', unchecked_value = '0'
  super view, builder, attribute_name, options
  @checked_value = checked_value
  @unchecked_value = unchecked_value
end

Instance Attribute Details

#checked_valueObject (readonly)

Returns the value of attribute checked_value.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def checked_value
  @checked_value
end

#unchecked_valueObject (readonly)

Returns the value of attribute unchecked_value.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def unchecked_value
  @unchecked_value
end

Class Method Details

.component_nameObject



13
14
15
# File 'lib/tao_form/components/radio_button_component.rb', line 13

def self.component_name
  :radio_button
end

Instance Method Details

#render(&block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/tao_form/components/radio_button_component.rb', line 17

def render &block
  if block_given?
    super
  else
    super {
      builder.radio_button attribute_name, {}, checked_value, unchecked_value
    }
  end
end