Class: CckForms::ParameterTypeClass::Boolean
- Inherits:
-
Object
- Object
- CckForms::ParameterTypeClass::Boolean
- Includes:
- Base
- Defined in:
- lib/cck_forms/parameter_type_class/boolean.rb
Overview
Represents a single checkbox.
Instance Method Summary collapse
-
#build_form(form_builder, options) ⇒ Object
Checkbox HTML.
-
#mongoize ⇒ Object
Anything -> boolean.
-
#to_s(_options = nil) ⇒ Object
‘yes/no’ string.
-
#value? ⇒ Boolean
Is it true?.
Instance Method Details
#build_form(form_builder, options) ⇒ Object
Checkbox HTML
22 23 24 25 |
# File 'lib/cck_forms/parameter_type_class/boolean.rb', line 22 def build_form(form_builder, ) set_value_in_hash form_builder.check_box :value, .merge(value: 1, checked: value?) end |
#mongoize ⇒ Object
Anything -> boolean
12 13 14 |
# File 'lib/cck_forms/parameter_type_class/boolean.rb', line 12 def mongoize value? end |
#to_s(_options = nil) ⇒ Object
‘yes/no’ string
17 18 19 |
# File 'lib/cck_forms/parameter_type_class/boolean.rb', line 17 def to_s( = nil) value? ? I18n.t('cck_forms.boolean.yes') : I18n.t('cck_forms.boolean.no') end |
#value? ⇒ Boolean
Is it true?
7 8 9 |
# File 'lib/cck_forms/parameter_type_class/boolean.rb', line 7 def value? value.present? && value != '0' end |