Class: SimpleAttribute::Attributes::Boolean
- Inherits:
-
Base
- Object
- Base
- SimpleAttribute::Attributes::Boolean
show all
- Defined in:
- lib/simple_attribute/attributes/boolean.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #options, #record, #value
Instance Method Summary
collapse
Methods inherited from Base
#attribute_name, #default_value, #defaults, #html_options, #initialize, #label_method, #method_missing, #render, #render_with_default, #render_wrapper, #renderer_name, #value?, #wrapper, #wrapper?
Instance Method Details
#false_class ⇒ Object
12
13
14
|
# File 'lib/simple_attribute/attributes/boolean.rb', line 12
def false_class
invert_classes? ? options[:true] : options[:false]
end
|
#invert_classes? ⇒ Boolean
4
5
6
|
# File 'lib/simple_attribute/attributes/boolean.rb', line 4
def invert_classes?
options[:invert] == true
end
|
#render_attribute ⇒ Object
27
28
29
|
# File 'lib/simple_attribute/attributes/boolean.rb', line 27
def render_attribute
'Yes'
end
|
#render_default_value ⇒ Object
23
24
25
|
# File 'lib/simple_attribute/attributes/boolean.rb', line 23
def render_default_value
'No'
end
|
#true_class ⇒ Object
8
9
10
|
# File 'lib/simple_attribute/attributes/boolean.rb', line 8
def true_class
invert_classes? ? options[:false] : options[:true]
end
|
#wrapper_html ⇒ Object
16
17
18
19
20
21
|
# File 'lib/simple_attribute/attributes/boolean.rb', line 16
def wrapper_html
classes = value? ? true_class : false_class
classes = "#{super[:class]} #{classes}".strip
super.merge(class: classes)
end
|