Module: Contrast::Config::Diagnostics::Tools

Extended by:
SingletonTools
Included in:
Contrast::Components::ComponentBase
Defined in:
lib/contrast/config/diagnostics/tools.rb

Overview

Diagnostics tools to be included in config components.

Constant Summary collapse

CHECK =
'd'

Constants included from SingletonTools

SingletonTools::API_CREDENTIALS, SingletonTools::CONTRAST_MARK

Instance Method Summary collapse

Methods included from SingletonTools

flatten_settings, to_config_values, update_config, value_to_s

Instance Method Details

#add_effective_config_values(effective_config, config_values, canonical_prefix, name_prefix = canonical_prefix) ⇒ Object

TODO: RUBY-2113 deprecate name_prefix

Converts current configuration from array of values to effective config values class and appends them to EffectiveConfig class. Must be used inside Config Components only.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/contrast/config/diagnostics/tools.rb', line 27

def add_effective_config_values(effective_config,
                                config_values,
                                canonical_prefix,
                                name_prefix = canonical_prefix)
  return if config_values.to_s.empty?

  config_values.each do |config_value_name|
    Contrast::Config::Diagnostics::EffectiveConfigValue.new.tap do |new_effective_value|
      config_value = send(config_value_name.to_sym)
      fill_effective_value(new_effective_value, config_value, config_value_name, canonical_prefix, name_prefix)
      effective_config.values << new_effective_value
    rescue StandardError => e
      log_error(e)
      next
    end
  end
end

#add_single_effective_value(effective_config, config_name, config_value, canonical_prefix, name_prefix = canonical_prefix) ⇒ Object

TODO: RUBY-2113 deprecate name_prefix

Converts current configuration from single value to effective config values class and appends them to EffectiveConfig class. Must be used inside Config Components only.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/contrast/config/diagnostics/tools.rb', line 55

def add_single_effective_value(effective_config,
                               config_name,
                               config_value,
                               canonical_prefix,
                               name_prefix = canonical_prefix)
  Contrast::Config::Diagnostics::EffectiveConfigValue.new.tap do |new_effective_value|
    fill_effective_value(new_effective_value, config_value, config_name, canonical_prefix, name_prefix)
    effective_config.values << new_effective_value
  rescue StandardError => e
    log_error(e)
    next
  end
end