Module: Roda::RodaPlugins::ParamMatchers::RequestMethods
- Defined in:
- lib/roda/plugins/param_matchers.rb
Instance Method Summary collapse
-
#match_param(key) ⇒ Object
Match the given parameter if present, even if the parameter is empty.
-
#match_param!(key) ⇒ Object
Match the given parameter if present and not empty.
-
#match_params(keys) ⇒ Object
Match all given parameters if present, even if any/all parameters is empty.
-
#match_params!(keys) ⇒ Object
Match all given parameters if present and not empty.
Instance Method Details
#match_param(key) ⇒ Object
Match the given parameter if present, even if the parameter is empty. Adds match to the captures.
39 40 41 42 43 |
# File 'lib/roda/plugins/param_matchers.rb', line 39 def match_param(key) if v = self[key] @captures << v end end |
#match_param!(key) ⇒ Object
Match the given parameter if present and not empty. Adds match to the captures.
47 48 49 50 51 |
# File 'lib/roda/plugins/param_matchers.rb', line 47 def match_param!(key) if (v = self[key]) && !v.empty? @captures << v end end |
#match_params(keys) ⇒ Object
Match all given parameters if present, even if any/all parameters is empty. Adds all matches to the captures.
55 56 57 58 59 |
# File 'lib/roda/plugins/param_matchers.rb', line 55 def match_params(keys) keys.each do |key| return false unless match_param(key) end end |
#match_params!(keys) ⇒ Object
Match all given parameters if present and not empty. Adds all matches to the captures.
63 64 65 66 67 |
# File 'lib/roda/plugins/param_matchers.rb', line 63 def match_params!(keys) keys.each do |key| return false unless match_param!(key) end end |