Sha256: 40a714a6bec7f7fdbdfb363f82a816fdc1678a126b8b2ea06eaedd2f7e9cfbc4
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
class Roda module RodaPlugins # The param_matchers plugin adds hash matchers that operate # on the request's params. # # It adds a :param matcher for matching on any param with the # same name, yielding the value of the param. # # r.on :param=>'foo' do |value| # # Matches '?foo=bar', '?foo=' # # Doesn't match '?bar=foo' # end # # It adds a :param! matcher for matching on any non-empty param # with the same name, yielding the value of the param # # r.on :param!=>'foo' do |value| # # Matches '?foo=bar' # # Doesn't match '?foo=', '?bar=foo' # end module ParamMatchers module RequestMethods # Match the given parameter if present, even if the parameter is empty. # Adds any match to the captures. def match_param(key) if v = self[key] @captures << v end end # Match the given parameter if present and not empty. # Adds any match to the captures. def match_param!(key) if (v = self[key]) && !v.empty? @captures << v end end end end register_plugin(:param_matchers, ParamMatchers) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roda-1.3.0 | lib/roda/plugins/param_matchers.rb |