aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-07-21 23:41:03 +0200
committerXavier Noria <fxn@hashref.com>2016-07-22 00:15:52 +0200
commit575dbeeefcaafeb566afc07cdd8b55603b698d9f (patch)
tree8371e5e85e11f242c0fbb6fb42fb63b5edac6fa4 /activesupport/lib
parentd4ea18a8cb84601509ee4c6dc691b212af8c2c36 (diff)
downloadrails-575dbeeefcaafeb566afc07cdd8b55603b698d9f.tar.gz
rails-575dbeeefcaafeb566afc07cdd8b55603b698d9f.tar.bz2
rails-575dbeeefcaafeb566afc07cdd8b55603b698d9f.zip
define Range#match? if Ruby < 2.4
See the rationale in the documentation included in this patch. We are going to gradually introduce this predicate in the code base.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/regexp.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/regexp.rb b/activesupport/lib/active_support/core_ext/regexp.rb
index 784145f5fb..d9cff52050 100644
--- a/activesupport/lib/active_support/core_ext/regexp.rb
+++ b/activesupport/lib/active_support/core_ext/regexp.rb
@@ -2,4 +2,8 @@ class Regexp #:nodoc:
def multiline?
options & MULTILINE == MULTILINE
end
+
+ def match?(string, pos=0)
+ !! match(string, pos)
+ end unless //.respond_to?(:match?)
end