Module: Sinatra::NamedRoute
- Defined in:
- lib/sinatra/named_route.rb,
lib/sinatra/named_route/version.rb
Defined Under Namespace
Modules: Helpers
Constant Summary collapse
- RouteNotFound =
Class.new(ArgumentError)
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.named_routes ⇒ Object
18 19 20 |
# File 'lib/sinatra/named_route.rb', line 18 def self.named_routes @named_routes ||= [] end |
.registered(app) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sinatra/named_route.rb', line 7 def self.registered(app) app.helpers Helpers app.set :named_routes_cache, {} app.set :named_routes, named_routes app.set :name do |key| settings.named_routes << { name: key } unless settings.named_routes.any? { |signature| key == signature[:name] } end end |
.route_added(verb, path, block) ⇒ Object
22 23 24 25 |
# File 'lib/sinatra/named_route.rb', line 22 def self.route_added(verb, path, block) signature = named_routes.last signature[:pattern] = Mustermann.new(path) end |