Class: Contrast::Config::BaseConfiguration

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/contrast/config/base_configuration.rb

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

BOOLEANS =
[true, false].cs__freeze
EMPTY_VALUE =
:EMPTY_VALUE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hsh = {}, keys = {}) ⇒ BaseConfiguration

Returns a new instance of BaseConfiguration.



27
28
29
30
# File 'lib/contrast/config/base_configuration.rb', line 27

def initialize hsh = {}, keys = {}
  @map = {}
  traverse_config(hsh, keys)
end

Instance Attribute Details

#mapObject (readonly) Also known as: to_hash

Returns the value of attribute map.



17
18
19
# File 'lib/contrast/config/base_configuration.rb', line 17

def map
  @map
end

Instance Method Details

#assign_value_to_path_array(dot_path_array, value) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/contrast/config/base_configuration.rb', line 32

def assign_value_to_path_array dot_path_array, value
  current_level = self
  dot_path_array[0...-1].each do |segment|
    current_level = current_level.send(segment) if current_level.cs__respond_to?(segment)
  end
  last_entry = dot_path_array[-1]
  current_level.send("#{ last_entry }=", value) if current_level.nil? == false && current_level.cs__respond_to?(last_entry)
  nil
end

#nil?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/contrast/config/base_configuration.rb', line 42

def nil?
  @map.empty?
end