aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-12-30 02:13:37 -0800
committerXavier Noria <fxn@hashref.com>2011-12-30 02:13:37 -0800
commitedfe7d80135465858bda841b0bc5991f14f35295 (patch)
tree2bb3e0a36e47c64e278c8813cbeb2700a07136a5 /activesupport/lib
parente43b2b35c7042c87fd18e3ecd55c14eabd5746ba (diff)
parent952e9d9005b775827b17227e040499d0324bb928 (diff)
downloadrails-edfe7d80135465858bda841b0bc5991f14f35295.tar.gz
rails-edfe7d80135465858bda841b0bc5991f14f35295.tar.bz2
rails-edfe7d80135465858bda841b0bc5991f14f35295.zip
Merge pull request #4229 from lest/range-include
refactor Range#include? to handle ranges with floats
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/range/include_range.rb3
1 files changed, 2 insertions, 1 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 c9986d4724..38a90490e6 100644
--- a/activesupport/lib/active_support/core_ext/range/include_range.rb
+++ b/activesupport/lib/active_support/core_ext/range/include_range.rb
@@ -9,7 +9,8 @@ class Range
# (5..9).include?(11) # => false
def include_with_range?(value)
if value.is_a?(::Range)
- min <= value.min && max >= value.max
+ operator = exclude_end? && !value.exclude_end? ? :< : :<=
+ include_without_range?(value.first) && value.last.send(operator, last)
else
include_without_range?(value)
end