Class: Anyway::Loaders::Doppler

Inherits:
Base
  • Object
show all
Defined in:
lib/anyway/loaders/doppler.rb

Defined Under Namespace

Classes: RequestError

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call, #initialize, #use_local?

Methods included from Tracing

capture, current_trace, current_trace_source, source_stack, trace!, trace_stack, with_trace_source

Constructor Details

This class inherits a constructor from Anyway::Loaders::Base

Class Attribute Details

.download_urlObject

Returns the value of attribute download_url.



15
16
17
# File 'lib/anyway/loaders/doppler.rb', line 15

def download_url
  @download_url
end

.tokenObject



18
19
20
# File 'lib/anyway/loaders/doppler.rb', line 18

def token
  @token || ENV["DOPPLER_TOKEN"]
end

Instance Method Details

#call(env_prefix:, **_options) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/anyway/loaders/doppler.rb', line 25

def call(env_prefix:, **_options)
  env_payload = parse_doppler_response(url: Doppler.download_url, token: Doppler.token)

  env = ::Anyway::Env.new(type_cast: ::Anyway::NoCast, env_container: env_payload)

  env.fetch_with_trace(env_prefix).then do |(conf, trace)|
    Tracing.current_trace&.merge!(trace)
    conf
  end
end