Module: ActiveSupport::IncludeTimeWithZone

Included in:
Range
Defined in:
lib/active_support/core_ext/range/include_time_with_zone.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#include?(value) ⇒ Boolean

Extends the default Range#include? to support ActiveSupport::TimeWithZone.

(1.hour.ago..1.hour.from_now).include?(Time.current) # => true

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
# File 'lib/active_support/core_ext/range/include_time_with_zone.rb', line 11

def include?(value)
  if self.begin.is_a?(TimeWithZone)
    cover?(value)
  elsif self.end.is_a?(TimeWithZone)
    cover?(value)
  else
    super
  end
end