Sha256: 6fc18b46f35fefb703f64aba6f7746c049a9e378b1c0ca7111e95d300d48b723

Contents?: true

Size: 548 Bytes

Versions: 37

Compression:

Stored size: 548 Bytes

Contents

# frozen_string_literal: true

require "active_support/time_with_zone"

module ActiveSupport
  module IncludeTimeWithZone #:nodoc:
    # Extends the default Range#include? to support ActiveSupport::TimeWithZone.
    #
    #   (1.hour.ago..1.hour.from_now).include?(Time.current) # => true
    #
    def include?(value)
      if self.begin.is_a?(TimeWithZone)
        cover?(value)
      elsif self.end.is_a?(TimeWithZone)
        cover?(value)
      else
        super
      end
    end
  end
end

Range.prepend(ActiveSupport::IncludeTimeWithZone)

Version data entries

37 entries across 37 versions & 6 rubygems

Version Path
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/core_ext/range/include_time_with_zone.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.6.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.6 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.5.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.5 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.8 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.7 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.6 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.5 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.4 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.3 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.2 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4.1 lib/active_support/core_ext/range/include_time_with_zone.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.4 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.3.7 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.3.6 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.3.5 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.0.3.4 lib/active_support/core_ext/range/include_time_with_zone.rb