module Roda::RodaPlugins::MatchHookArgs::ClassMethods

  1. lib/roda/plugins/match_hook_args.rb

Methods

Public Instance

  1. add_match_hook
  2. freeze

Public Instance methods

add_match_hook(&block)

Add a match hook that will be called with matchers and block args.

[show source]
   # File lib/roda/plugins/match_hook_args.rb
50 def add_match_hook(&block)
51   opts[:match_hook_args] << define_roda_method("match_hook_args", :any, &block)
52 
53   if opts[:match_hook_args].length == 1
54     class_eval("alias _match_hook_args #{opts[:match_hook_args].first}", __FILE__, __LINE__)
55   else
56     class_eval("def _match_hook_args(v, a); #{opts[:match_hook_args].map{|m| "#{m}(v, a)"}.join(';')} end", __FILE__, __LINE__)
57   end
58 
59   public :_match_hook_args
60 
61   nil
62 end
freeze()

Freeze the array of hook methods when freezing the app

[show source]
   # File lib/roda/plugins/match_hook_args.rb
44 def freeze
45   opts[:match_hook_args].freeze
46   super
47 end