aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-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+
...