Class: TypedEAV::Field::Integer
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- ApplicationRecord
- Base
- TypedEAV::Field::Integer
- Defined in:
- app/models/typed_eav/field/integer.rb
Constant Summary
Constants inherited from Base
Constants included from ColumnMapping
ColumnMapping::DEFAULT_OPERATORS_BY_COLUMN, ColumnMapping::FALLBACK_OPERATORS
Instance Method Summary collapse
Methods inherited from Base
#allowed_option_values, #array_field?, #clear_option_cache!, #default_value, #default_value=, #field_type_name, #optionable?
Instance Method Details
#cast(raw) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/typed_eav/field/integer.rb', line 12 def cast(raw) return [nil, false] if raw.nil? str = raw.to_s.strip return [nil, false] if str.empty? bd = BigDecimal(str, exception: false) return [nil, true] if bd.nil? return [nil, true] if bd.frac != 0 [bd.to_i, false] end |
#validate_typed_value(record, val) ⇒ Object
25 26 27 |
# File 'app/models/typed_eav/field/integer.rb', line 25 def validate_typed_value(record, val) validate_range(record, val) end |