Class: Primer::Router
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Primer::Router
- Defined in:
- lib/primer/route_set.rb
Defined Under Namespace
Classes: Request
Class Method Summary collapse
-
.new(*args) ⇒ Object
Circumvent the fact that Sinatra::Base.new creates a Rack stack.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(path) ⇒ Router
constructor
A new instance of Router.
Constructor Details
Class Method Details
.new(*args) ⇒ Object
Circumvent the fact that Sinatra::Base.new creates a Rack stack
29 30 31 |
# File 'lib/primer/route_set.rb', line 29 def self.new(*args) Class.instance_method(:new).bind(self).call(*args) end |
Instance Method Details
#evaluate ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/primer/route_set.rb', line 38 def evaluate routes = self.class.routes['GET'] catch(:halt) { routes.each do |pattern, keys, conditions, block| process_route(pattern, keys, conditions) do throw(:halt, instance_eval(&block)) end end raise RouteNotFound.new("No route match found for key #{@request.path_info}") } end |