Module: Roda::RodaPlugins::HashBranches::RequestMethods
- Defined in:
- lib/roda/plugins/hash_branches.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.
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.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/roda/plugins/hash_branches.rb', line 123 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 |