module Pretzel::Routing::Evaluation::ClassMethods
For all regex lovers.
Public Instance Methods
compile_route(pattern)
click to toggle source
# File lib/pretzel/routing/eval.rb, line 11 def compile_route(pattern) keys = [] pattern = pattern[0...-1] if pattern.end_with?("/") pattern.gsub!(/(:\w+)/) do # Get all colon-prefixed params keys << $1[1..-1] # Put the name of them into the keys array. "([^/?#]+)" # Substitute with a capture group. end # Return the regex and the param names. if pattern != "/" # No trailing slash for the root route. [%r{^#{pattern}\/?$}, keys] else [%r{^#{pattern}$}, keys] end end