aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-09-26 03:48:49 +0200
committerXavier Noria <fxn@hashref.com>2009-09-26 03:48:49 +0200
commitc63e19c8a0ccca1ad30b90bc262f11919f5397c1 (patch)
tree495775bf28797d0cfa27d9f28151c3f744393338 /railties/guides
parent23566b071cf211e36d57b09898675fa73e2e7882 (diff)
downloadrails-c63e19c8a0ccca1ad30b90bc262f11919f5397c1.tar.gz
rails-c63e19c8a0ccca1ad30b90bc262f11919f5397c1.tar.bz2
rails-c63e19c8a0ccca1ad30b90bc262f11919f5397c1.zip
AS guide: documents Regexp#multiline?
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/active_support_overview.textile25
1 files changed, 25 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile
index 89c959c49f..9c3610dc2c 100644
--- a/railties/guides/source/active_support_overview.textile
+++ b/railties/guides/source/active_support_overview.textile
@@ -1573,6 +1573,31 @@ def recognition_extraction
end
</ruby>
+h4. +multiline?+
+
+The method +multiline?+ says whether a regexp has the +/m+ flag set, that is, whether the dot matches newlines.
+
+<ruby>
+%r{.}.multiline? # => false
+%r{.}m.multiline? # => true
+
+Regexp.new('.').multiline? # => false
+Regexp.new('.', Regexp::MULTILINE).multiline? # => true
+</ruby>
+
+Rails uses this method in a single place, also in the routing code. Multiline regexps are disallowed for route requirements and this flag eases enforcing that constraint.
+
+<ruby>
+def assign_route_options(segments, defaults, requirements)
+ ...
+ if requirement.multiline?
+ raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
+ end
+ ...
+end
+</ruby>
+
+
h3. Extensions to +Range+
...