instance method
compare_with_coercion
Ruby on Rails 4.2.9
Since v3.0.20Signature
compare_with_coercion(other)
Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared with a Time
Parameters
-
otherreq
Source
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 258
def compare_with_coercion(other)
# we're avoiding Time#to_datetime cause it's expensive
if other.class == Time
compare_without_coercion(other)
elsif other.is_a?(Time)
compare_without_coercion(other.to_time)
else
to_datetime <=> other
end
end
Defined in activesupport/lib/active_support/core_ext/time/calculations.rb line 258
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Time