module Roda::RodaPlugins::HashBranchViewSubdir::ClassMethods

  1. lib/roda/plugins/hash_branch_view_subdir.rb

Methods

Public Instance

  1. freeze
  2. hash_branch
  3. inherited

Public Instance methods

freeze()

Freeze the hash_branch_view_subdir metadata when freezing the app.

[show source]
   # File lib/roda/plugins/hash_branch_view_subdir.rb
39 def freeze
40   hash_branch_view_subdir_methods.freeze.each_value(&:freeze)
41   super
42 end
hash_branch(namespace='', segment, &block)

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.

[show source]
   # File lib/roda/plugins/hash_branch_view_subdir.rb
57 def hash_branch(namespace='', segment, &block)
58   meths = hash_branch_view_subdir_methods[namespace] ||= {}
59 
60   if block
61     meth = meths[segment] = define_roda_method(meths[segment] || "_hash_branch_view_subdir_#{namespace}_#{segment}", 1, &convert_route_block(block))
62     super do |*_|
63       append_view_subdir(segment)
64       send(meth, @_request)
65     end
66   else
67     if meth = meths.delete(segment)
68       remove_method(meth)
69     end
70     super
71   end
72 end
inherited(subclass)

Duplicate hash_branch_view_subdir metadata in subclass.

[show source]
   # File lib/roda/plugins/hash_branch_view_subdir.rb
45 def inherited(subclass)
46   super
47 
48   h = subclass.hash_branch_view_subdir_methods
49   hash_branch_view_subdir_methods.each do |namespace, routes|
50     h[namespace] = routes.dup
51   end
52 end