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