Module: Contrast::Config::BaseConfiguration

Overview

This is the base for our configuration classes. It is intended to facilitate the translation of the Common Configuration settings to usable Ruby classes.

Constant Summary collapse

AT_UNDERSCORE =
'@_'

Instance Method Summary collapse

Instance Method Details

#to_contrast_hashObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/contrast/config/base_configuration.rb', line 15

def to_contrast_hash
  hsh = {}
  instance_variables.each do |iv|
    # strip the '@' of '@_' to get the key
    string_iv = iv.to_s
    key = if string_iv.include?(AT_UNDERSCORE)
            string_iv[2..]
          else
            string_iv[1..]
          end
    hsh[key] = send(key.to_sym)
  end
  hsh
end