Rails Range cover? includes? methods support Range argument
Rails CompareWithRange
core extension adds support
of
Range as an argument
to Range#===
, Range#cover?
and Range#includes?
methods.
Ruby already has support for these three methods,
but ruby does not support Range value as an argument.
This change is targetted to release and deprecate
old active_support/core_ext/range/include_range
with Rails 6.1.
Prior to Rails@fa9d01d
Range did support value as a Range
argument for the method Range#include?
.
Till then, native implementation of Range#include
did not support
value as a range argument.
For Rails > 4.2.7
For Rails <= 4.2.7
Check the include_with_range documentation for more details.
Source code:
Rails keeps default behavior untouched.
Relevant source code of Range#include?
from Rails ActiveSupport can be seen below.
After Rails@fa9d01d
Two new methods have been defined to have similar methods as we have in Ruby 2.6.
Range#===
Range#include?
Range#cover?
The commit
also added a deprecation waring with include_range
file as given below.
Subscribe to Ruby in Rails
Get the latest posts delivered right to your inbox