Module: Roda::RodaPlugins::HashBranchViewNamespace::ClassMethods
- Defined in:
- lib/roda/plugins/hash_branch_view_namespace.rb
Instance Method Summary collapse
- #freeze ⇒ Object
- #hash_branch(namespace = '', segment, &block) ⇒ Object
- #inherited(subclass) ⇒ Object
Instance Method Details
#freeze ⇒ Object
16 17 18 19 |
# File 'lib/roda/plugins/hash_branch_view_namespace.rb', line 16 def freeze opts[:hash_branch_view_subdir_methods].freeze.each_value(&:freeze) super end |
#hash_branch(namespace = '', segment, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/roda/plugins/hash_branch_view_namespace.rb', line 30 def hash_branch(namespace='', segment, &block) meths = opts[:hash_branch_view_subdir_methods][namespace] ||= {} if block meth = meths[segment] = define_roda_method(meths[segment] || "_hash_branch_view_subdir_#{namespace}_#{segment}", 1, &convert_route_block(block)) super do |*_| append_view_subdir(namespace.to_s << "/" << segment) send(meth, @_request) end else if meth = meths.delete(segment) remove_method(meth) end super end end |
#inherited(subclass) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/roda/plugins/hash_branch_view_namespace.rb', line 21 def inherited(subclass) super h = subclass.opts[:hash_branch_view_subdir_methods] opts[:hash_branch_view_subdir_methods].each do |namespace, routes| h[namespace] = routes.dup end end |