Module: Datadog::Environment::Helpers

Included in:
Datadog::Environment
Defined in:
lib/ddtrace/environment.rb

Overview

Defines helper methods for environment

Instance Method Summary collapse

Instance Method Details

#env_to_bool(var, default = nil) ⇒ Object



8
9
10
# File 'lib/ddtrace/environment.rb', line 8

def env_to_bool(var, default = nil)
  ENV.key?(var) ? ENV[var].to_s.downcase == 'true' : default
end

#env_to_float(var, default = nil) ⇒ Object



12
13
14
# File 'lib/ddtrace/environment.rb', line 12

def env_to_float(var, default = nil)
  ENV.key?(var) ? ENV[var].to_f : default
end

#env_to_list(var, default = []) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/ddtrace/environment.rb', line 16

def env_to_list(var, default = [])
  if ENV.key?(var)
    ENV[var].split(',').map(&:strip)
  else
    default
  end
end