Sha256: d22dc937c8f1cf907ca119e600dbc49d96006913cde821bb77d8fb7b963a8985
Contents?: true
Size: 987 Bytes
Versions: 2
Compression:
Stored size: 987 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 # Yield the block with the handler installed # # @api private def call(stack, dynamic = EMPTY_HASH) if dynamic.empty? @dictionary = static else @dictionary = static.merge(dynamic) end super(stack) end # @param [Effect] effect # @return [Boolean] # @api public 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.1 | lib/dry/effects/providers/implicit.rb |
dry-effects-0.1.0 | lib/dry/effects/providers/implicit.rb |