Class: ServiceSkeleton::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/service_skeleton/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, service_name, variables) ⇒ Config

Returns a new instance of Config.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/service_skeleton/config.rb', line 13

def initialize(env, service_name, variables)
  @service_name = service_name

  # Parsing variables will redact the environment, so we want to take a
  # private unredacted copy before that happens for #[] lookup in the
  # future.
  @env = env.to_hash.dup.freeze

  parse_variables(internal_variables + variables, env)

  # Sadly, we can't setup the logger until we know *how* to setup the
  # logger, which requires parsing config variables
  setup_logger
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



11
12
13
# File 'lib/service_skeleton/config.rb', line 11

def env
  @env
end

#loggerObject (readonly)

Returns the value of attribute logger.



11
12
13
# File 'lib/service_skeleton/config.rb', line 11

def logger
  @logger
end

#pre_run_loggerObject (readonly)

Returns the value of attribute pre_run_logger.



11
12
13
# File 'lib/service_skeleton/config.rb', line 11

def pre_run_logger
  @pre_run_logger
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



11
12
13
# File 'lib/service_skeleton/config.rb', line 11

def service_name
  @service_name
end

Instance Method Details

#[](k) ⇒ Object



28
29
30
# File 'lib/service_skeleton/config.rb', line 28

def [](k)
  @env[k].dup
end