Sha256: 233915cda3d9e93e170bd84957263d40e0bfdb1efe8f36efe0085abfe87a6b21

Contents?: true

Size: 878 Bytes

Versions: 42

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

require "active_support/time_with_zone"
require "active_support/deprecation"

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) || self.end.is_a?(TimeWithZone)
        ActiveSupport::Deprecation.warn(<<-MSG.squish)
          Using `Range#include?` to check the inclusion of a value in
          a date time range is deprecated.
          It is recommended to use `Range#cover?` instead of `Range#include?` to
          check the inclusion of a value in a date time range.
        MSG
        cover?(value)
      else
        super
      end
    end
  end
end

Range.prepend(ActiveSupport::IncludeTimeWithZone)

Version data entries

42 entries across 42 versions & 7 rubygems

Version Path
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/core_ext/range/include_time_with_zone.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/core_ext/range/include_time_with_zone.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/core_ext/range/include_time_with_zone.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.4.4 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.4.3 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.4.2 lib/active_support/core_ext/range/include_time_with_zone.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/core_ext/range/include_time_with_zone.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.4.1 lib/active_support/core_ext/range/include_time_with_zone.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.4 lib/active_support/core_ext/range/include_time_with_zone.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.3.2 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.3.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.3 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.2.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.2 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.1 lib/active_support/core_ext/range/include_time_with_zone.rb
activesupport-6.1.0 lib/active_support/core_ext/range/include_time_with_zone.rb