lib/contrast/config/base_configuration.rb in contrast-agent-6.0.0 vs lib/contrast/config/base_configuration.rb in contrast-agent-6.1.0
- old
+ new
@@ -4,24 +4,15 @@
require 'forwardable'
require 'contrast/utils/object_share'
module Contrast
module Config
- # This is the base for our configuration classes. It is intended to
- # facilitate the translation of the Common Configuration settings to usable
- # Ruby classes.
- class BaseConfiguration
+ # This is the base for our configuration classes. It is intended to facilitate the translation of the Common
+ # Configuration settings to usable Ruby classes.
+ module BaseConfiguration
extend Forwardable
- EMPTY_VALUE = :EMPTY_VALUE
-
- def initialize hsh = {}, keys = {}
- # holds configuration key value pairs
- # each configuration class can contain nested BaseConfigurations
- traverse_config(hsh, keys)
- end
-
def to_hash
hsh = {}
instance_variables.each do |iv|
# strip the '@' to get the key
key = iv.to_s[1..]
@@ -39,32 +30,9 @@
last_entry = dot_path_array[-1]
if current_level.nil? == false && current_level.cs__respond_to?(last_entry)
current_level.send("#{ last_entry }=", value)
end
nil
- end
-
- private
-
- # Traverse the given entity to build out the configuration graph.
- #
- # The values will be either a hash, indicating internal nodes to
- # traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
- # leaf node.
- #
- # The spec_key are the Contrast defined keys based on the instance variables of
- # a given configuration.
- def traverse_config values, spec_key
- internal_nodes = values.cs__respond_to?(:has_key?)
- val = internal_nodes ? value_from_key_config(spec_key, values) : nil
- val == EMPTY_VALUE ? nil : val
- end
-
- def value_from_key_config key, config_hash
- return config_hash[key] if config_hash.key?(key)
- return config_hash.fetch(key.to_sym, nil) if key.is_a?(String)
-
- config_hash.fetch(key.to_s, nil)
end
end
end
end