Class: Regexp
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.optionalize(pattern) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/action_controller/routing.rb', line 36 def optionalize(pattern) case unoptionalize(pattern) when /\A(.|\(.*\))\Z/ then "#{pattern}?" else "(?:#{pattern})?" end end |
.unoptionalize(pattern) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/action_controller/routing.rb', line 43 def unoptionalize(pattern) [/\A\(\?:(.*)\)\?\Z/, /\A(.|\(.*\))\?\Z/].each do |regexp| return $1 if regexp =~ pattern end return pattern end |