Sha256: ff7b1b5173d09c08461b011d9c0ff959a3237639073834600eaf5d6e5d0ea9e6

Contents?: true

Size: 597 Bytes

Versions: 1

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Effects
    module Effects
      class Timeout < ::Module
        class TimeoutEffect < Effect
          include ::Dry::Equalizer(:type, :name, :scope)

          option :scope
        end

        def initialize(scope)
          super()

          timeout = TimeoutEffect.new(type: :timeout, name: :timeout, scope: scope)

          module_eval do
            define_method(:timeout) do
              ::Dry::Effects.yield(timeout)
            end

            def timed_out? = timeout.zero?
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-effects-0.5.0 lib/dry/effects/effects/timeout.rb