Method: Dry::Effects::Frame#call

Defined in:
lib/dry/effects/frame.rb

#call(*args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add new handler to the current stack and run the given block

Parameters:

  • args (Array<Object>)

    Handler arguments

  • block (Proc)

    Program to run



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/dry/effects/frame.rb', line 76

def call(*args, &block)
  stack = Frame.stack
  prov = provider.dup
  was_empty = stack.empty?

  prov.(*args) do
    if was_empty
      stack.push(prov) do
        Frame.spawn_fiber(stack, &block)
      end
    else
      stack.push(prov, &block)
    end
  end
end