Module: Canned::Context::Matchers::Has

Included in:
Actor, Resource
Defined in:
lib/canned/context/matchers/has.rb

Instance Method Summary collapse

Instance Method Details

#has(_key, _options = {}, &_block) ⇒ Object Also known as: have

Acts on one of the top resource’s attributes

Examples:
   upon { loaded(:raffle).has(:app_id) { equal_to(20) or less_than(20) } }
   upon { loaded(:raffle).has('ceil(upper)').greater_than(20)


12
13
14
15
16
17
# File 'lib/canned/context/matchers/has.rb', line 12

def has(_key, _options={}, &_block)
  _chain_context(Canned::Context::Value, _block) do |stack|
    value = Helpers.resolve(stack.top, _key)
    stack.push(:value, _options.fetch(:as, _key), value)
  end
end