lib/roda/plugins/hash_matcher.rb in roda-2.29.0 vs lib/roda/plugins/hash_matcher.rb in roda-3.0.0
- old
+ new
@@ -10,11 +10,11 @@
# hash_matcher(:foo) do |v|
# self['foo'] == v
# end
#
# route do
- # r.on :foo=>'bar' do
+ # r.on foo: 'bar' do
# # matches when param foo has value bar
# end
# end
# end
module HashMatcher
@@ -23,10 +23,12 @@
# 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.
def hash_matcher(key, &block)
- self::RodaRequest.send(:define_method, :"match_#{key}", &block)
+ meth = :"match_#{key}"
+ self::RodaRequest.send(:define_method, meth, &block)
+ self::RodaRequest.send(:private, meth)
end
end
end
register_plugin(:hash_matcher, HashMatcher)