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.
49 50 51 52 53 |
# File 'lib/roda/plugins/param_matchers.rb', line 49 def match_param(key) if v = params[key.to_s] @captures << v end end |
#match_param!(key) ⇒ Object
Match the given parameter if present and not empty. Adds match to the captures.
57 58 59 60 61 |
# File 'lib/roda/plugins/param_matchers.rb', line 57 def match_param!(key) if (v = params[key.to_s]) && !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.
65 66 67 68 69 |
# File 'lib/roda/plugins/param_matchers.rb', line 65 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.
73 74 75 76 77 |
# File 'lib/roda/plugins/param_matchers.rb', line 73 def match_params!(keys) keys.each do |key| return false unless match_param!(key) end end |