Module: Canned::Context::Matchers::AsksWith
Instance Method Summary collapse
-
#asked_with(_key, _options = {}, &_block) ⇒ Object
(also: #asks_with)
Loads a value context for a given parameter.
-
#asked_with_id(_key, _options = {}, &_block) ⇒ Object
(also: #asks_with_id)
Same as asked_with but transforms parameter to an int.
Instance Method Details
#asked_with(_key, _options = {}, &_block) ⇒ Object Also known as: asks_with
Loads a value context for a given parameter
of that returned by this function.
14 15 16 17 18 19 20 |
# File 'lib/canned/context/matchers/asks_with.rb', line 14 def asked_with(_key, ={}, &_block) _chain_context(Canned::Context::Value, _block) do |stack| param = @ctx.params[_key] next false if param.nil? stack.push :value, .fetch(:as, _key), param end end |
#asked_with_id(_key, _options = {}, &_block) ⇒ Object Also known as: asks_with_id
Same as asked_with but transforms parameter to an int.
24 25 26 27 28 29 30 |
# File 'lib/canned/context/matchers/asks_with.rb', line 24 def asked_with_id(_key, ={}, &_block) _chain_context(Canned::Context::Value, _block) do |stack| param = @ctx.params[_key] next false if param.nil? stack.push :value, .fetch(:as, _key), param.to_i end end |