Class: Dry::Effects::Providers::Env
- Inherits:
-
Object
- Object
- Dry::Effects::Providers::Env
- Defined in:
- lib/dry/effects/providers/env.rb
Constant Summary collapse
- Locate =
Effect.new(type: :env, name: :locate)
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#call(values = EMPTY_HASH, options = EMPTY_HASH) ⇒ Object
private
Yield the block with the handler installed.
- #key?(key) ⇒ Boolean
-
#locate ⇒ Provider
private
Locate handler in the stack.
- #provide?(effect) ⇒ Boolean
- #read(key) ⇒ Object
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'lib/dry/effects/providers/env.rb', line 13 def parent @parent end |
Instance Method Details
#call(values = EMPTY_HASH, options = 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
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dry/effects/providers/env.rb', line 37 def call(values = EMPTY_HASH, = EMPTY_HASH) unless values.empty? @values = @values.merge(values) end if .fetch(:overridable, false) @parent = ::Dry::Effects.yield(Locate) { EMPTY_HASH } else @parent = EMPTY_HASH end yield end |
#key?(key) ⇒ Boolean
62 63 64 |
# File 'lib/dry/effects/providers/env.rb', line 62 def key?(key) values.key?(key) || (key.is_a?(::String) && ::ENV.key?(key)) || parent.key?(key) end |
#locate ⇒ Provider
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.
Locate handler in the stack
32 |
# File 'lib/dry/effects/providers/env.rb', line 32 def locate = self |
#provide?(effect) ⇒ Boolean
54 55 56 57 58 59 60 |
# File 'lib/dry/effects/providers/env.rb', line 54 def provide?(effect) if super !effect.name.equal?(:read) || key?(effect.payload[0]) else false end end |
#read(key) ⇒ Object
15 |
# File 'lib/dry/effects/providers/env.rb', line 15 def read(key) = parent.fetch(key) { fetch(key) } |