Sha256: c4b1c790530810ca3e92a81bebeca40ef6c9be7fc5fab955e4a560eefd7841d1

Contents?: true

Size: 697 Bytes

Versions: 28

Compression:

Stored size: 697 Bytes

Contents

module CustomAttributes
  class FloatFieldType < Numeric
    include Singleton

    def cast_single_value(_custom_field, value, _customizable = nil)
      value.to_f
    end

    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
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
create_custom_attributes-0.6.3 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.6.2 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.6.1 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.25 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.24 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.23 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.22 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.21 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.20 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.19 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.18 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.17 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.16 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.15 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.14 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.13 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.12 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.11 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.10 lib/custom_attributes/field_types/float_field_type.rb
create_custom_attributes-0.5.9 lib/custom_attributes/field_types/float_field_type.rb