Module: Roda::RodaPlugins::HashMatcher::ClassMethods
- Defined in:
- lib/roda/plugins/hash_matcher.rb
Instance Method Summary collapse
-
#hash_matcher(key, &block) ⇒ Object
Create a match_#key method in the request class using the given block, so that using a hash key in a request match method will call the block.
Instance Method Details
#hash_matcher(key, &block) ⇒ Object
Create a match_#key method in the request class using the given block, so that using a hash key in a request match method will call the block. The block should return nil or false to not match, and anything else to match. See the HashMatcher module documentation for an example.
27 28 29 30 31 |
# File 'lib/roda/plugins/hash_matcher.rb', line 27 def hash_matcher(key, &block) meth = :"match_#{key}" self::RodaRequest.send(:define_method, meth, &block) self::RodaRequest.send(:private, meth) end |