Class: Dry::Effects::Providers::Interrupt

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/effects/providers/interrupt.rb

Instance Method Summary collapse

Instance Method Details

#callObject

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.

Yield the block with the handler installed



16
17
18
19
20
# File 'lib/dry/effects/providers/interrupt.rb', line 16

def call
  [false, yield]
rescue halt => e
  [true, e.payload[0]]
end

#haltObject



22
23
24
# File 'lib/dry/effects/providers/interrupt.rb', line 22

def halt
  Halt[scope]
end

#interrupt(*payload) ⇒ Object



9
10
11
# File 'lib/dry/effects/providers/interrupt.rb', line 9

def interrupt(*payload)
  Instructions.Raise(halt.new(payload))
end

#provide?(effect) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


35
36
37
# File 'lib/dry/effects/providers/interrupt.rb', line 35

def provide?(effect)
  super && scope.equal?(effect.scope)
end

#representString

Returns:

  • (String)


28
29
30
# File 'lib/dry/effects/providers/interrupt.rb', line 28

def represent
  "interrupt[#{scope}]"
end