diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-05-22 14:14:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-22 14:14:56 -0400 |
commit | fa9d01d7ddbe18cabd31bcc86b6aa86ac02eff48 (patch) | |
tree | a3e8f280ccda596e1590b39807460d0c6d7de744 /activesupport/lib/active_support/core_ext/range/include_range.rb | |
parent | 7ee898ca18797c70ed71605087474032e2289909 (diff) | |
parent | e04a79e772fc9d016d73138c3f322212f3b6ead7 (diff) | |
download | rails-fa9d01d7ddbe18cabd31bcc86b6aa86ac02eff48.tar.gz rails-fa9d01d7ddbe18cabd31bcc86b6aa86ac02eff48.tar.bz2 rails-fa9d01d7ddbe18cabd31bcc86b6aa86ac02eff48.zip |
Merge pull request #32938 from utilum/range_case_equality
Allow Range#=== and Range#cover? on Range
Diffstat (limited to 'activesupport/lib/active_support/core_ext/range/include_range.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/range/include_range.rb | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/activesupport/lib/active_support/core_ext/range/include_range.rb b/activesupport/lib/active_support/core_ext/range/include_range.rb index 7ba1011921..2da2c587a3 100644 --- a/activesupport/lib/active_support/core_ext/range/include_range.rb +++ b/activesupport/lib/active_support/core_ext/range/include_range.rb @@ -1,25 +1,9 @@ # frozen_string_literal: true -module ActiveSupport - module IncludeWithRange #:nodoc: - # Extends the default Range#include? to support range comparisons. - # (1..5).include?(1..5) # => true - # (1..5).include?(2..3) # => true - # (1..5).include?(2..6) # => false - # - # The native Range#include? behavior is untouched. - # ('a'..'f').include?('c') # => true - # (5..9).include?(11) # => false - def include?(value) - if value.is_a?(::Range) - # 1...10 includes 1..9 but it does not include 1..10. - operator = exclude_end? && !value.exclude_end? ? :< : :<= - super(value.first) && value.last.send(operator, last) - else - super - end - end - end -end +require "active_support/deprecation" -Range.prepend(ActiveSupport::IncludeWithRange) +ActiveSupport::Deprecation.warn "You have required `active_support/core_ext/range/include_range`. " \ +"This file will be removed in Rails 6.1. You should require `active_support/core_ext/range/compare_range` " \ + "instead." + +require "active_support/core_ext/range/compare_range" |