Class: Contrast::Config::Diagnostics::SourceConfigValue
- Defined in:
- lib/contrast/config/diagnostics/source_config_value.rb
Overview
All config values from all sources, stored in a easy to write representation.
Direct Known Subclasses
Constant Summary collapse
- NULL =
'null'
Instance Attribute Summary collapse
-
#canonical_name ⇒ String
Name of the config starting form root of yaml config.
-
#filename ⇒ String?
The filename for the source of the config, if the source was “yaml”.
-
#key ⇒ String
Name of the config.
-
#source ⇒ String
The source for the entry in the config.
-
#value ⇒ String, ...
Value set for the config.
Instance Method Summary collapse
-
#assign_filename(source) ⇒ Array<String>?
Assigns file name of the config iv viable, Currently supported formats for config file are *.yaml and *.yml.
- #to_controlled_hash ⇒ Object
- #to_source_hash ⇒ Object
Instance Attribute Details
#canonical_name ⇒ String
Returns Name of the config starting form root of yaml config.
15 16 17 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 15 def canonical_name @canonical_name end |
#filename ⇒ String?
Returns The filename for the source of the config, if the source was “yaml”.
23 24 25 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 23 def filename @filename end |
#key ⇒ String
Returns Name of the config.
17 18 19 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 17 def key @key end |
#source ⇒ String
Returns The source for the entry in the config.
21 22 23 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 21 def source @source end |
#value ⇒ String, ...
Returns Value set for the config. Current Effective Value.
19 20 21 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 19 def value @value end |
Instance Method Details
#assign_filename(source) ⇒ Array<String>?
Assigns file name of the config iv viable, Currently supported formats for config file are *.yaml and *.yml. For the config loaded from file the filename is kept as source.
48 49 50 51 52 53 54 55 56 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 48 def assign_filename source Contrast::Components::Config::Sources::APP_CONFIGURATION_EXTENSIONS.each do |type| # We use the source to transfer the file's name from the mapping of the extensions. # This is done b/c the user_configuration file has a second field to be filled, # and other sources don't. Transfer the source as filename and set the default value # for it later when we find the sources. instance_variable_set(:@filename, source) if source.include?(".#{ type.downcase }") end end |
#to_controlled_hash ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 25 def to_controlled_hash { canonical_name: canonical_name, name: key || Contrast::Utils::ObjectShare::EMPTY_STRING, value: Contrast::Config::Diagnostics::Tools.value_to_s(value), source: source || Contrast::Utils::ObjectShare::EMPTY_STRING, filename: filename || Contrast::Utils::ObjectShare::EMPTY_STRING } end |
#to_source_hash ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/contrast/config/diagnostics/source_config_value.rb', line 35 def to_source_hash { canonical_name: canonical_name, name: key || Contrast::Utils::ObjectShare::EMPTY_STRING, value: Contrast::Config::Diagnostics::Tools.value_to_s(value) } end |