Class: ActiveModel::Type::BigInteger
- Defined in:
- activemodel/lib/active_model/type/big_integer.rb
Overview
Active Model BigInteger Type
Attribute type for integers that can be serialized to an unlimited number of bytes. This type is registered under the :big_integer
key.
class Person
include ActiveModel::Attributes
attribute :id, :big_integer
end
person = Person.new
person.id = "18_000_000_000"
person.id # => 18000000000
All casting and serialization are performed in the same way as the standard ActiveModel::Type::Integer type.
Direct Known Subclasses
Constant Summary
Constants inherited from Integer
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
- #serializable?(value) ⇒ Boolean
-
#serialize(value) ⇒ Object
:nodoc:.
-
#serialize_cast_value(value) ⇒ Object
:nodoc:.
Methods inherited from Integer
#deserialize, #initialize, #type
Methods included from Helpers::Numeric
Methods included from Helpers::Immutable
Methods inherited from Value
#==, #as_json, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #initialize, #map, #mutable?, #serialized?, #type, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Methods included from SerializeCastValue
included, #initialize, #itself_if_serialize_cast_value_compatible, serialize
Methods included from ActiveSupport::Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Constructor Details
This class inherits a constructor from ActiveModel::Type::Integer
Instance Method Details
#serializable?(value) ⇒ Boolean
47 48 49 |
# File 'activemodel/lib/active_model/type/big_integer.rb', line 47 def serializable?(value, &) true end |
#serialize(value) ⇒ Object
:nodoc:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'activemodel/lib/active_model/type/big_integer.rb', line 26 def serialize(value) # :nodoc: case value when ::Integer # noop when ::String int = value.to_i if int.zero? && value != "0" return if non_numeric_string?(value) end value = int else value = super end value end |
#serialize_cast_value(value) ⇒ Object
:nodoc:
43 44 45 |
# File 'activemodel/lib/active_model/type/big_integer.rb', line 43 def serialize_cast_value(value) # :nodoc: value end |