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.
62 63 64 65 |
# File 'lib/roda/plugins/static_routing.rb', line 62 def freeze opts[:static_routes].freeze.each_value(&:freeze) super end |
#inherited(subclass) ⇒ Object
Duplicate static route metadata in subclass.
68 69 70 71 72 73 74 |
# File 'lib/roda/plugins/static_routing.rb', line 68 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.
81 82 83 |
# File 'lib/roda/plugins/static_routing.rb', line 81 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.
86 87 88 89 90 |
# File 'lib/roda/plugins/static_routing.rb', line 86 def static_route_for(method, path) if h = opts[:static_routes][path] h[method] || h[nil] end end |