Sha256: 0249d1bd4c1526c87353dfb8e45dd94310382ce340891eb2cea0e4e1349715bf
Contents?: true
Size: 818 Bytes
Versions: 2
Compression:
Stored size: 818 Bytes
Contents
# frozen_string_literal: true require 'dry/effects/provider' module Dry module Effects module Providers class Implicit < Provider[:implicit] include Dry::Equalizer(:name, :static, :dictionary) param :dependency param :static, default: -> { EMPTY_HASH } attr_reader :dictionary def implicit(arg) dictionary.fetch(arg.class) end def call(stack, dynamic = EMPTY_HASH) if dynamic.empty? @dictionary = static else @dictionary = static.merge(dynamic) end super(stack) end def provide?(effect) super && dependency.equal?(effect.dependency) && dictionary.key?(effect.payload[0].class) 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/providers/implicit.rb |
dry-effects-0.1.0.alpha | lib/dry/effects/providers/implicit.rb |