Public Instance methods
freeze()
Freeze the hash_branches metadata when freezing the app.
[show source]
# File lib/roda/plugins/hash_branches.rb 92 def freeze 93 opts[:hash_branches].freeze.each_value(&:freeze) 94 super 95 end
hash_branch(namespace='', segment, &block)
Add branch handler for the given namespace and segment. If called without a block, removes the existing branch handler if it exists.
[show source]
# File lib/roda/plugins/hash_branches.rb 109 def hash_branch(namespace='', segment, &block) 110 segment = "/#{segment}" 111 routes = opts[:hash_branches][namespace] ||= {} 112 if block 113 routes[segment] = define_roda_method(routes[segment] || "hash_branch_#{namespace}_#{segment}", 1, &convert_route_block(block)) 114 elsif meth = routes.delete(segment) 115 remove_method(meth) 116 end 117 end
inherited(subclass)
Duplicate hash_branches metadata in subclass.
[show source]
# File lib/roda/plugins/hash_branches.rb 98 def inherited(subclass) 99 super 100 101 h = subclass.opts[:hash_branches] 102 opts[:hash_branches].each do |namespace, routes| 103 h[namespace] = routes.dup 104 end 105 end