class Aladdin::Support::OneOfMatcher
Sinatra route matcher that matches mutltiple paths given in an array.
Constants
- Match
Public Class Methods
new(routes)
click to toggle source
Creates a new matcher for routes
. @param [Array] routes array of static paths
# File lib/aladdin/support/multiroute.rb, line 13 def initialize(routes) @routes = routes.map { |r| '/' + r } @captures = Match.new [] end
Public Instance Methods
match(str)
click to toggle source
Matches routes
against str
.
# File lib/aladdin/support/multiroute.rb, line 19 def match(str) @captures[:captures] = [str] @captures if @routes.any? { |r| str.starts_with? r } end