Sha256: fa472ee1025f38f5d186e947437d76a0a67fc0f53604c3e7553984f30db52b03

Contents?: true

Size: 636 Bytes

Versions: 6

Compression:

Stored size: 636 Bytes

Contents

# frozen_string_literal: true

require 'dry/effects/effect'

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

          option :scope
        end

        def initialize(scope)
          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

6 entries across 6 versions & 1 rubygems

Version Path
dry-effects-0.1.5 lib/dry/effects/effects/timeout.rb
dry-effects-0.1.4 lib/dry/effects/effects/timeout.rb
dry-effects-0.1.3 lib/dry/effects/effects/timeout.rb
dry-effects-0.1.2 lib/dry/effects/effects/timeout.rb
dry-effects-0.1.1 lib/dry/effects/effects/timeout.rb
dry-effects-0.1.0 lib/dry/effects/effects/timeout.rb