Sha256: d2874d30cf7bebd5ea545010849eac339c23198460733889c2a4d830262feaff

Contents?: true

Size: 625 Bytes

Versions: 3

Compression:

Stored size: 625 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
end

Version data entries

3 entries across 3 versions & 1 rubygems

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