class Rack::Multiplexer::Routes
Public Class Methods
new()
click to toggle source
# File lib/rack/multiplexer.rb, line 79 def initialize @routes = [] end
Public Instance Methods
<<(route)
click to toggle source
# File lib/rack/multiplexer.rb, line 91 def <<(route) @routes << route end
find(path)
click to toggle source
# File lib/rack/multiplexer.rb, line 83 def find(path) if regexp === path @routes.size.times do |i| return @routes[i] if Regexp.last_match("_#{i}") end end end
Private Instance Methods
regexp()
click to toggle source
# File lib/rack/multiplexer.rb, line 97 def regexp @regexp ||= begin regexps = @routes.map.with_index {|route, index| /(?<_#{index}>#{route.regexp})/ } /\A#{Regexp.union(regexps)}\z/ end end