mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use serializable?
instead of rescue ::RangeError
This commit is contained in:
parent
3b6461bb46
commit
4607f13c88
2 changed files with 7 additions and 5 deletions
|
@ -56,6 +56,10 @@ module ActiveModel
|
|||
type.serialize(value)
|
||||
end
|
||||
|
||||
def serializable?
|
||||
type.serializable?(value)
|
||||
end
|
||||
|
||||
def changed?
|
||||
changed_from_assignment? || changed_in_place?
|
||||
end
|
||||
|
|
|
@ -20,19 +20,17 @@ module ActiveRecord
|
|||
def nil?
|
||||
unless value_before_type_cast.is_a?(StatementCache::Substitute)
|
||||
value_before_type_cast.nil? ||
|
||||
type.respond_to?(:subtype, true) && value_for_database.nil?
|
||||
type.respond_to?(:subtype) && serializable? && value_for_database.nil?
|
||||
end
|
||||
rescue ::RangeError
|
||||
end
|
||||
|
||||
def infinite?
|
||||
infinity?(value_before_type_cast) || infinity?(value_for_database)
|
||||
rescue ::RangeError
|
||||
infinity?(value_before_type_cast) || serializable? && infinity?(value_for_database)
|
||||
end
|
||||
|
||||
def unboundable?
|
||||
unless defined?(@_unboundable)
|
||||
@_unboundable = !type.serializable?(value) && type.cast(value) <=> 0
|
||||
@_unboundable = !serializable? && type.cast(value) <=> 0
|
||||
end
|
||||
@_unboundable
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue