Public Instance methods
freeze()
Freeze the hash_paths metadata when freezing the app.
[show source]
# File lib/roda/plugins/hash_paths.rb 84 def freeze 85 opts[:hash_paths].freeze.each_value(&:freeze) 86 super 87 end
hash_path(namespace='', path, &block)
Add path handler for the given namespace and path. When the r.hash_paths method is called, checks the matching namespace for the full remaining path, and dispatch to that block if there is one. If called without a block, removes the existing path handler if it exists.
[show source]
# File lib/roda/plugins/hash_paths.rb 104 def hash_path(namespace='', path, &block) 105 routes = opts[:hash_paths][namespace] ||= {} 106 if block 107 routes[path] = define_roda_method(routes[path] || "hash_path_#{namespace}_#{path}", 1, &convert_route_block(block)) 108 elsif meth = routes.delete(path) 109 remove_method(meth) 110 end 111 end
inherited(subclass)
Duplicate hash_paths metadata in subclass.
[show source]
# File lib/roda/plugins/hash_paths.rb 90 def inherited(subclass) 91 super 92 93 h = subclass.opts[:hash_paths] 94 opts[:hash_paths].each do |namespace, routes| 95 h[namespace] = routes.dup 96 end 97 end