Module: Canned::Context::Matchers::The

Included in:
Default
Defined in:
lib/canned/context/matchers/the.rb

Instance Method Summary collapse

Instance Method Details

#the(_name, _options = {}, &_block) ⇒ Object

Loads an actor and returns an actor context.

of that returned by this function.

Parameters:

  • _name (String|Symbol)

    Actor name

  • _options (Hash) (defaults to: {})

    Various options:

    • as: If given, the actor will use as as alias for where blocks instead of the name.

  • _block (Block)

    If given, then the block will be evaluated in the actor’s context and the result



14
15
16
17
18
19
20
# File 'lib/canned/context/matchers/the.rb', line 14

def the(_name, _options={}, &_block)
  _chain_context(Canned::Context::Actor, _block) do |stack|
    actor = @ctx.actors[_name]
    next false if actor.nil?
    stack.push(:actor, _options.fetch(:as, _name), actor)
  end
end