Sha256: 2935b88bd4f88768ce8ff71b10fcb47095033fb91619c3e8a54dcbe3719586b8

Contents?: true

Size: 539 Bytes

Versions: 62

Compression:

Stored size: 539 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 first.is_a?(TimeWithZone)
        cover?(value)
      elsif last.is_a?(TimeWithZone)
        cover?(value)
      else
        super
      end
    end
  end
end

Range.prepend(ActiveSupport::IncludeTimeWithZone)

Version data entries

62 entries across 56 versions & 8 rubygems

Version Path
activesupport-5.2.8.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.8 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.7.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.7 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.6.3 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.6.2 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.6.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.6 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4.6 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.5 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4.5 lib/active_support/core_ext/range/include_time_with_zone.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4.4 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4.3 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4.2 lib/active_support/core_ext/range/include_time_with_zone.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.4.1/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4.1 lib/active_support/core_ext/range/include_time_with_zone.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/core_ext/range/include_time_with_zone.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-5.2.4 lib/active_support/core_ext/range/include_time_with_zone.rb