Class: Contrast::Configuration
- Extended by:
- Forwardable
- Includes:
- Contrast::Components::Interface
- Defined in:
- lib/contrast/configuration.rb
Overview
This is how we read in the local settings for the Agent, both ENV/ CMD line and from properties files, in order to determine which settings, if any, the user has overridden.
Constant Summary collapse
- DEFAULT_YAML_PATH =
'contrast_security.yaml'- MILLISECOND_MARKER =
'_ms'- CONVERSION =
{ 'agent.service.enable' => 'agent.start_bundled_service' }.cs__freeze
- CONFIG_BASE_PATHS =
[ '', 'config/', '/etc/contrast/ruby/', '/etc/contrast/', '/etc/' ].cs__freeze
Instance Attribute Summary collapse
-
#default_name ⇒ Object
readonly
Returns the value of attribute default_name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(cli_options = nil, default_name = DEFAULT_YAML_PATH) ⇒ Configuration
constructor
A new instance of Configuration.
-
#loggable ⇒ String
Get a loggable YAML format of this configuration.
-
#method_missing(symbol, *args) ⇒ Object
Because we call this method to determine the need for scoping, it itself must be executed inside a Contrast scope.
- #respond_to_missing?(method_name, *args) ⇒ Boolean
Methods included from Contrast::Components::Interface
Constructor Details
#initialize(cli_options = nil, default_name = DEFAULT_YAML_PATH) ⇒ Configuration
Returns a new instance of Configuration.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/contrast/configuration.rb', line 39 def initialize = nil, default_name = DEFAULT_YAML_PATH @default_name = default_name # Load config_kv from file config_kv = deep_stringify_all_keys(load_config) # Overlay CLI options - they take precedence over config file = deep_stringify_all_keys() config_kv = deep_merge(, config_kv) if # Some in-flight rewrites to maintain backwards compatibility config_kv = update_prop_keys(config_kv) @root = Contrast::Config::RootConfiguration.new(config_kv) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
Because we call this method to determine the need for scoping, it itself must be executed inside a Contrast scope. Failure to do so could result in an infinite loop on the to_sym method used later.
58 59 60 61 62 63 64 |
# File 'lib/contrast/configuration.rb', line 58 def method_missing symbol, *args with_contrast_scope do root.public_send(symbol, *args) rescue NoMethodError => _e super end end |
Instance Attribute Details
#default_name ⇒ Object (readonly)
Returns the value of attribute default_name.
24 25 26 |
# File 'lib/contrast/configuration.rb', line 24 def default_name @default_name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
24 25 26 |
# File 'lib/contrast/configuration.rb', line 24 def root @root end |
Instance Method Details
#loggable ⇒ String
Get a loggable YAML format of this configuration
73 74 75 |
# File 'lib/contrast/configuration.rb', line 73 def loggable convert_to_hash.to_yaml end |
#respond_to_missing?(method_name, *args) ⇒ Boolean
66 67 68 |
# File 'lib/contrast/configuration.rb', line 66 def respond_to_missing? method_name, *args root&.cs__respond_to?(method_name) || super end |