Class: Dry::Effects::Providers::Implicit

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/effects/providers/implicit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dictionaryObject (readonly)

Returns the value of attribute dictionary.



13
14
15
# File 'lib/dry/effects/providers/implicit.rb', line 13

def dictionary
  @dictionary
end

Instance Method Details

#call(dynamic = EMPTY_HASH) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yield the block with the handler installed



22
23
24
25
26
27
28
29
30
# File 'lib/dry/effects/providers/implicit.rb', line 22

def call(dynamic = EMPTY_HASH)
  if dynamic.empty?
    @dictionary = static
  else
    @dictionary = static.merge(dynamic)
  end

  yield
end

#implicit(arg) ⇒ Object



15
16
17
# File 'lib/dry/effects/providers/implicit.rb', line 15

def implicit(arg)
  dictionary.fetch(arg.class)
end

#provide?(effect) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/dry/effects/providers/implicit.rb', line 35

def provide?(effect)
  super &&
    dependency.equal?(effect.dependency) &&
    dictionary.key?(effect.payload[0].class)
end