Class: SimpleAttribute::Attributes::Boolean
- Defined in:
- lib/simple_attribute/attributes/boolean.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #options, #record, #value
Instance Method Summary collapse
-
#false_class ⇒ Object
False class.
-
#invert_classes? ⇒ Boolean
Invert classes.
-
#render_attribute ⇒ Object
Render attribute.
-
#render_default_value ⇒ Object
Render default attribute.
-
#true_class ⇒ Object
True class.
-
#wrapper_html ⇒ Object
Wrapper html.
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?
Constructor Details
This class inherits a constructor from SimpleAttribute::Attributes::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SimpleAttribute::Attributes::Base
Instance Method Details
#false_class ⇒ Object
False class
15 16 17 |
# File 'lib/simple_attribute/attributes/boolean.rb', line 15 def false_class invert_classes? ? [:true] : [:false] end |
#invert_classes? ⇒ Boolean
Invert classes
5 6 7 |
# File 'lib/simple_attribute/attributes/boolean.rb', line 5 def invert_classes? [:invert] == true end |
#render_attribute ⇒ Object
Render attribute
33 34 35 |
# File 'lib/simple_attribute/attributes/boolean.rb', line 33 def render_attribute 'Yes' end |
#render_default_value ⇒ Object
Render default attribute
28 29 30 |
# File 'lib/simple_attribute/attributes/boolean.rb', line 28 def render_default_value 'No' end |
#true_class ⇒ Object
True class
10 11 12 |
# File 'lib/simple_attribute/attributes/boolean.rb', line 10 def true_class invert_classes? ? [:false] : [:true] end |
#wrapper_html ⇒ Object
Wrapper html
20 21 22 23 24 25 |
# File 'lib/simple_attribute/attributes/boolean.rb', line 20 def wrapper_html classes = value? ? true_class : false_class classes = "#{super[:class]} #{classes}".strip super.merge(class: classes) end |