module Roda::RodaPlugins::HashBranches::RequestMethods

  1. lib/roda/plugins/hash_branches.rb

Methods

Public Instance

  1. hash_branches

Public Instance methods

hash_branches(namespace=matched_path)

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.

[show source]
    # File lib/roda/plugins/hash_branches.rb
123 def hash_branches(namespace=matched_path)
124   rp = @remaining_path
125 
126   return unless rp.getbyte(0) == 47 # "/"
127 
128   if routes = roda_class.opts[:hash_branches][namespace]
129     if segment_end = rp.index('/', 1)
130       if meth = routes[rp[0, segment_end]]
131         @remaining_path = rp[segment_end, 100000000]
132         always{scope.send(meth, self)}
133       end
134     elsif meth = routes[rp]
135       @remaining_path = ''
136       always{scope.send(meth, self)}
137     end
138   end
139 end