Module: Roda::RodaPlugins::HashRoutes::RequestMethods
- Defined in:
- lib/roda/plugins/hash_routes.rb
Instance Method Summary collapse
-
#hash_branches(namespace = matched_path) ⇒ Object
Checks the matching hash_branch namespace for a branch matching the next segment in the remaining path, and dispatch to that block if there is one.
-
#hash_paths(namespace = matched_path) ⇒ Object
Checks the matching hash_path namespace for a branch matching the remaining path, and dispatch to that block if there is one.
-
#hash_routes(namespace = matched_path) ⇒ Object
Check for matches in both the hash_path and hash_branch namespaces for a matching remaining path or next segment in the remaining path, respectively.
Instance Method Details
#hash_branches(namespace = matched_path) ⇒ Object
Checks the matching hash_branch namespace for a branch matching the next segment in the remaining path, and dispatch to that block if there is one.
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/roda/plugins/hash_routes.rb', line 429 def hash_branches(namespace=matched_path) rp = @remaining_path return unless rp.getbyte(0) == 47 # "/" if routes = roda_class.opts[:hash_branches][namespace] if segment_end = rp.index('/', 1) if meth = routes[rp[0, segment_end]] @remaining_path = rp[segment_end, 100000000] always{scope.send(meth, self)} end elsif meth = routes[rp] @remaining_path = '' always{scope.send(meth, self)} end end end |
#hash_paths(namespace = matched_path) ⇒ Object
Checks the matching hash_path namespace for a branch matching the remaining path, and dispatch to that block if there is one.
449 450 451 452 453 454 |
# File 'lib/roda/plugins/hash_routes.rb', line 449 def hash_paths(namespace=matched_path) if (routes = roda_class.opts[:hash_paths][namespace]) && (meth = routes[@remaining_path]) @remaining_path = '' always{scope.send(meth, self)} end end |
#hash_routes(namespace = matched_path) ⇒ Object
Check for matches in both the hash_path and hash_branch namespaces for a matching remaining path or next segment in the remaining path, respectively.
458 459 460 461 |
# File 'lib/roda/plugins/hash_routes.rb', line 458 def hash_routes(namespace=matched_path) hash_paths(namespace) hash_branches(namespace) end |