Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ruby 3.3 Range#overlap? if available #49317

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Use Ruby 3.3 Range#overlap? if available

*Yasuo Honda*

## Rails 7.1.0.beta1 (September 13, 2023) ##

* Add `drb`, `mutex_m` and `base64` that are bundled gem candidates for Ruby 3.4
Expand Down
6 changes: 4 additions & 2 deletions activesupport/lib/active_support/core_ext/range/overlap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ class Range
# Compare two ranges and see if they overlap each other
# (1..5).overlap?(4..6) # => true
# (1..5).overlap?(7..9) # => false
def overlap?(other)
other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin)
unless Range.method_defined?(:overlap?)
def overlap?(other)
other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin)
end
end

alias :overlaps? :overlap?
Expand Down