Class: ConsulApplicationSettings::Resolvers::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/consul_application_settings/resolvers/env.rb

Overview

Resolve values in environment

Constant Summary collapse

IDENTIFIER =
'env://'.freeze

Instance Method Summary collapse

Instance Method Details

#resolvable?(value, _path) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/consul_application_settings/resolvers/env.rb', line 7

def resolvable?(value, _path)
  return unless value.respond_to?(:start_with?)

  value.start_with?(IDENTIFIER)
end

#resolve(value, _path) ⇒ Object



13
14
15
16
# File 'lib/consul_application_settings/resolvers/env.rb', line 13

def resolve(value, _path)
  env_path = value.to_s.delete_prefix(IDENTIFIER)
  ENV[env_path]
end