Sha256: 3457ce1cba7aa9d24c7a5d5d1a509c56d48ed75409ffa32078ea2799623d64a5
Contents?: true
Size: 929 Bytes
Versions: 4
Compression:
Stored size: 929 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 # Yield the block with the handler installed # # @api private def call [false, yield] rescue halt => e [true, e.payload[0]] end def halt Halt[scope] end # @return [String] # @api public def represent "interrupt[#{scope}]" end # @param [Effect] effect # @return [Boolean] # @api public def provide?(effect) super && scope.equal?(effect.scope) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems