Module: CustomFields::Types::Boolean::Target::ClassMethods
- Defined in:
- lib/custom_fields/types/boolean.rb
Instance Method Summary collapse
-
#apply_boolean_custom_field(klass, rule) ⇒ Object
Adds a boolean field.
-
#boolean_attribute_get(instance, name) ⇒ Hash
Build a hash storing the boolean value (true / false) for a boolean custom field of an instance.
-
#boolean_attribute_set(instance, name, attributes) ⇒ Object
Set the value for the instance and the boolean field specified by the 2 params.
Instance Method Details
#apply_boolean_custom_field(klass, rule) ⇒ Object
Adds a boolean field. It can not be required.
17 18 19 20 |
# File 'lib/custom_fields/types/boolean.rb', line 17 def apply_boolean_custom_field(klass, rule) klass.field rule['name'], type: 'Boolean', localize: rule['localized'] || false, default: rule['default'].nil? ? false : rule['default'] end |
#boolean_attribute_get(instance, name) ⇒ Hash
Build a hash storing the boolean value (true / false) for a boolean custom field of an instance.
30 31 32 |
# File 'lib/custom_fields/types/boolean.rb', line 30 def boolean_attribute_get(instance, name) default_attribute_get(instance, name) end |
#boolean_attribute_set(instance, name, attributes) ⇒ Object
Set the value for the instance and the boolean field specified by the 2 params.
41 42 43 |
# File 'lib/custom_fields/types/boolean.rb', line 41 def boolean_attribute_set(instance, name, attributes) default_attribute_set(instance, name, attributes) end |