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.
20 21 22 |
# File 'lib/custom_fields/types/boolean.rb', line 20 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.
32 33 34 |
# File 'lib/custom_fields/types/boolean.rb', line 32 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.
43 44 45 |
# File 'lib/custom_fields/types/boolean.rb', line 43 def boolean_attribute_set(instance, name, attributes) self.default_attribute_set(instance, name, attributes) end |