module Roda::RodaPlugins::HashPaths::ClassMethods
Public Instance Methods
Source
# File lib/roda/plugins/hash_paths.rb, line 84 def freeze opts[:hash_paths].freeze.each_value(&:freeze) super end
Freeze the hash_paths metadata when freezing the app.
Calls superclass method
Source
# File lib/roda/plugins/hash_paths.rb, line 104 def hash_path(namespace='', path, &block) routes = opts[:hash_paths][namespace] ||= {} if block routes[path] = define_roda_method(routes[path] || "hash_path_#{namespace}_#{path}", 1, &convert_route_block(block)) elsif meth = routes.delete(path) remove_method(meth) end end
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.
Source
# File lib/roda/plugins/hash_paths.rb, line 90 def inherited(subclass) super h = subclass.opts[:hash_paths] opts[:hash_paths].each do |namespace, routes| h[namespace] = routes.dup end end
Duplicate hash_paths metadata in subclass.
Calls superclass method