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.
42 43 44 45 46 |
# File 'lib/roda/plugins/param_matchers.rb', line 42 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.
50 51 52 53 54 |
# File 'lib/roda/plugins/param_matchers.rb', line 50 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.
58 59 60 61 62 |
# File 'lib/roda/plugins/param_matchers.rb', line 58 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.
66 67 68 69 70 |
# File 'lib/roda/plugins/param_matchers.rb', line 66 def match_params!(keys) keys.each do |key| return false unless match_param!(key) end end |