Module: CustomFields::Types::Float::Target::ClassMethods
- Defined in:
- lib/custom_fields/types/float.rb
Instance Method Summary collapse
-
#apply_float_custom_field(klass, rule) ⇒ Object
Add a string field.
-
#float_attribute_get(instance, name) ⇒ Hash
Build a hash storing the raw value for a string custom field of an instance.
-
#float_attribute_set(instance, name, attributes) ⇒ Object
Set the value for the instance and the string field specified by the 2 params.
Instance Method Details
#apply_float_custom_field(klass, rule) ⇒ Object
Add a string field
17 18 19 20 21 |
# File 'lib/custom_fields/types/float.rb', line 17 def apply_float_custom_field(klass, rule) klass.field rule['name'], type: ::Float, localize: rule['localized'] || false, default: rule['default'] klass.validates_presence_of rule['name'] if rule['required'] klass.validates rule['name'], numericality: true, if: ->(_x) { rule['required'] } end |
#float_attribute_get(instance, name) ⇒ Hash
Build a hash storing the raw value for a string custom field of an instance.
31 32 33 |
# File 'lib/custom_fields/types/float.rb', line 31 def float_attribute_get(instance, name) default_attribute_get(instance, name) end |
#float_attribute_set(instance, name, attributes) ⇒ Object
Set the value for the instance and the string field specified by the 2 params.
42 43 44 |
# File 'lib/custom_fields/types/float.rb', line 42 def float_attribute_set(instance, name, attributes) default_attribute_set(instance, name, attributes) end |