Module: Roda::RodaPlugins::StaticRouting::ClassMethods
- Defined in:
- lib/roda/plugins/static_routing.rb
Instance Method Summary collapse
-
#freeze ⇒ Object
Freeze the static route metadata when freezing the app.
-
#inherited(subclass) ⇒ Object
Duplicate static route metadata in subclass.
-
#static_route(path, &block) ⇒ Object
Add a static route for any request method.
-
#static_route_for(method, path) ⇒ Object
Return the static route for the given request method and path.
Instance Method Details
#freeze ⇒ Object
Freeze the static route metadata when freezing the app.
61 62 63 64 |
# File 'lib/roda/plugins/static_routing.rb', line 61 def freeze opts[:static_routes].freeze.each_value(&:freeze) super end |
#inherited(subclass) ⇒ Object
Duplicate static route metadata in subclass.
67 68 69 70 71 72 73 |
# File 'lib/roda/plugins/static_routing.rb', line 67 def inherited(subclass) super static_routes = subclass.opts[:static_routes] opts[:static_routes].each do |k, v| static_routes[k] = v.dup end end |
#static_route(path, &block) ⇒ Object
Add a static route for any request method. These are tried after the request method specific static routes (e.g. static_get), but allow you to use Roda’s routing tree methods inside the route for handling shared behavior while still allowing request method specific handling.
80 81 82 |
# File 'lib/roda/plugins/static_routing.rb', line 80 def static_route(path, &block) add_static_route(nil, path, &block) end |
#static_route_for(method, path) ⇒ Object
Return the static route for the given request method and path.
85 86 87 88 89 |
# File 'lib/roda/plugins/static_routing.rb', line 85 def static_route_for(method, path) if h = opts[:static_routes][path] h[method] || h[nil] end end |