Sha256: 40f889f0173cead9e4842cbe87dbcf81d1e7d706bd16fa87184734857d4bccc2

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

require "dry/effects/effect"
require "dry/effects/constructors"

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

          option :scope
        end

        Constructors.register(:Retry) do |scope|
          Retry.new(type: :retry, scope: scope)
        end

        def initialize
          super

          module_eval do
            define_method(:repeat) do |scope|
              effect = Retry.new(type: :retry, scope: scope)
              ::Dry::Effects.yield(effect)
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-effects-0.3.0 lib/dry/effects/effects/retry.rb
dry-effects-0.2.0 lib/dry/effects/effects/retry.rb