Sha256: b2fb39521adcdde4afb9dbd34ab46cf7d8d07fb92fe16baaa0e9c2e997882ceb
Contents?: true
Size: 991 Bytes
Versions: 4
Compression:
Stored size: 991 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, inspect: false) 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(dynamic = EMPTY_HASH) if dynamic.empty? @dictionary = static else @dictionary = static.merge(dynamic) end yield 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
4 entries across 4 versions & 1 rubygems