Sha256: 27a30ae157b8a9e9776655e1e239a9a551a797ea4f742c0fc9b63d068b5248a7

Contents?: true

Size: 586 Bytes

Versions: 2

Compression:

Stored size: 586 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)

        def Constructors.Resolve(key)
          Resolve.(key)
        end

        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

2 entries across 2 versions & 1 rubygems

Version Path
dry-effects-0.1.0.alpha2 lib/dry/effects/effects/resolve.rb
dry-effects-0.1.0.alpha lib/dry/effects/effects/resolve.rb