module Roda::RodaPlugins::HashBranches::ClassMethods

  1. lib/roda/plugins/hash_branches.rb

Methods

Public Instance

  1. freeze
  2. hash_branch
  3. inherited

Public Instance methods

freeze()

Freeze the hash_branches metadata when freezing the app.

[show source]
   # File lib/roda/plugins/hash_branches.rb
94 def freeze
95   hash_branches.freeze.each_value(&:freeze)
96   super
97 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
111 def hash_branch(namespace='', segment, &block)
112   segment = "/#{segment}"
113   routes = hash_branches[namespace] ||= {}
114   if block
115     routes[segment] = define_roda_method(routes[segment] || "hash_branch_#{namespace}_#{segment}", 1, &convert_route_block(block))
116   elsif meth = routes.delete(segment)
117     remove_method(meth)
118   end
119 end
inherited(subclass)

Duplicate hash_branches metadata in subclass.

[show source]
    # File lib/roda/plugins/hash_branches.rb
100 def inherited(subclass)
101   super
102 
103   h = subclass.hash_branches
104   hash_branches.each do |namespace, routes|
105     h[namespace] = routes.dup
106   end
107 end