Sha256: f39ef4e10de636ff23c7d9ef4ef4d67f88d7746860e7e435f8bcc1c5dbe47321

Contents?: true

Size: 668 Bytes

Versions: 4

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Effects
    module Effects
      class Interrupt < ::Module
        class InterruptEffect < Effect
          option :scope
        end

        def initialize(scope = :default)
          super()

          interrupt = InterruptEffect.new(type: :interrupt, scope: scope)

          module_eval do
            define_method(scope) do |payload = Undefined|
              if Undefined.equal?(payload)
                ::Dry::Effects.yield(interrupt)
              else
                ::Dry::Effects.yield(interrupt.payload(payload))
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-effects-0.5.0 lib/dry/effects/effects/interrupt.rb
dry-effects-0.4.1 lib/dry/effects/effects/interrupt.rb
dry-effects-0.4.0 lib/dry/effects/effects/interrupt.rb
dry-effects-0.3.1 lib/dry/effects/effects/interrupt.rb