Module: Roda::RodaPlugins::HashBranchViewSubdir::ClassMethods
- Defined in:
- lib/roda/plugins/hash_branch_view_subdir.rb
Instance Method Summary collapse
-
#freeze ⇒ Object
Freeze the hash_branch_view_subdir metadata when freezing the app.
-
#hash_branch(namespace = '', segment, &block) ⇒ Object
Automatically append a view subdirectory for a successful hash_branch route, by modifying the generated method to append the view subdirectory before dispatching to the original block.
-
#inherited(subclass) ⇒ Object
Duplicate hash_branch_view_subdir metadata in subclass.
Instance Method Details
#freeze ⇒ Object
Freeze the hash_branch_view_subdir metadata when freezing the app.
37 38 39 40 |
# File 'lib/roda/plugins/hash_branch_view_subdir.rb', line 37 def freeze opts[:hash_branch_view_subdir_methods].freeze.each_value(&:freeze) super end |
#hash_branch(namespace = '', segment, &block) ⇒ Object
Automatically append a view subdirectory for a successful hash_branch route, by modifying the generated method to append the view subdirectory before dispatching to the original block.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/roda/plugins/hash_branch_view_subdir.rb', line 55 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(segment) send(meth, @_request) end else if meth = meths.delete(segment) remove_method(meth) end super end end |
#inherited(subclass) ⇒ Object
Duplicate hash_branch_view_subdir metadata in subclass.
43 44 45 46 47 48 49 50 |
# File 'lib/roda/plugins/hash_branch_view_subdir.rb', line 43 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 |