Module: ConsulWatcher::ClassHelper

Defined in:
lib/consul_watcher/class_helper.rb

Overview

Define methods to handle default initialization behavior

Instance Method Summary collapse

Instance Method Details

#populate_variables(config = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/consul_watcher/class_helper.rb', line 6

def populate_variables(config = {})
  defaults.each_pair do |key, default_value|
    key = key.to_s
    if config[key]
      instance_variable_set("@#{key}", config[key])
    elsif ENV[key.upcase.to_s]
      instance_variable_set("@#{key}", ENV[key.upcase.to_s])
    else
      instance_variable_set("@#{key}", default_value)
    end
  end
end