Sha256: 7294bacb30f276814cd700b67b2337ba6134250928eeef4cd7c937be43c2e40b

Contents?: true

Size: 576 Bytes

Versions: 6

Compression:

Stored size: 576 Bytes

Contents

# frozen_string_literal: true

require 'dry/effects/effect'
require 'dry/effects/constructors'

module Dry
  module Effects
    module Effects
      class Resolve < ::Module
        Resolve = Effect.new(type: :resolve)

        Constructors.register(:Resolve) { |key| Resolve.(key) }

        def initialize(*keys, **aliases)
          module_eval do
            (keys.zip(keys) + aliases.to_a).each do |name, key|
              define_method(name) { |&block| ::Dry::Effects.yield(Resolve.(key), &block) }
            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/resolve.rb
dry-effects-0.1.4 lib/dry/effects/effects/resolve.rb
dry-effects-0.1.3 lib/dry/effects/effects/resolve.rb
dry-effects-0.1.2 lib/dry/effects/effects/resolve.rb
dry-effects-0.1.1 lib/dry/effects/effects/resolve.rb
dry-effects-0.1.0 lib/dry/effects/effects/resolve.rb