Class: CustomAttributes::FloatFieldType
- Inherits:
-
Numeric
show all
- Includes:
- Singleton
- Defined in:
- lib/custom_attributes/field_types/float_field_type.rb
Instance Method Summary
collapse
Methods inherited from FieldType
#after_save_custom_value, available_types, #before_custom_field_save, #cast_custom_value, #cast_value, #edit_tag, find, #label, #name, #possible_custom_value_options, #possible_values_options, #set_custom_field_value, #validate_custom_field, #validate_custom_value, #value_from_keyword
Instance Method Details
#cast_single_value(_custom_field, value, _customizable = nil) ⇒ Object
5
6
7
|
# File 'lib/custom_attributes/field_types/float_field_type.rb', line 5
def cast_single_value(_custom_field, value, _customizable = nil)
value.to_f
end
|
#validate_single_value(custom_field, value, customizable = nil) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/custom_attributes/field_types/float_field_type.rb', line 9
def validate_single_value(custom_field, value, customizable = nil)
errs = super
errs << ::I18n.t('activerecord.errors.messages.invalid') unless begin
Kernel.Float(value)
rescue
nil
end
errs
end
|