Sha256: f5d818aef8352080a29972262b211f50e3f5cfeaf79d1afa44ee620037691d6e
Contents?: true
Size: 702 Bytes
Versions: 2
Compression:
Stored size: 702 Bytes
Contents
# frozen_string_literal: true require 'dry/effects/provider' require 'dry/effects/instructions/raise' require 'dry/effects/halt' module Dry module Effects module Providers class Interrupt < Provider[:interrupt] param :scope, default: -> { :default } def interrupt(*payload) Instructions.Raise(halt.new(payload)) end def call(_stack) yield rescue halt => e e.payload[0] end def halt Halt[scope] end def represent "interrupt[#{scope}]" end def provide?(effect) super && scope.equal?(effect.scope) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-effects-0.1.0.alpha2 | lib/dry/effects/providers/interrupt.rb |
dry-effects-0.1.0.alpha | lib/dry/effects/providers/interrupt.rb |