Class: ScoutApm::Config
- Inherits:
-
Object
- Object
- ScoutApm::Config
- Defined in:
- lib/scout_apm/config.rb
Defined Under Namespace
Classes: BooleanCoercion, ConfigDefaults, ConfigEnvironment, ConfigFile, ConfigNull, JsonCoercion, NullCoercion
Constant Summary collapse
- SETTING_COERCIONS =
{ "monitor" => BooleanCoercion.new, "enable_background_jobs" => BooleanCoercion.new, "dev_trace" => BooleanCoercion.new, "ignore" => JsonCoercion.new, }
Class Method Summary collapse
-
.with_file(file_path = nil, config = {}) ⇒ Object
Load up a config instance, attempting to load a yaml file.
-
.without_file ⇒ Object
Load up a config instance without attempting to load a file.
Instance Method Summary collapse
-
#initialize(overlays) ⇒ Config
constructor
A new instance of Config.
- #value(key) ⇒ Object
Constructor Details
#initialize(overlays) ⇒ Config
Returns a new instance of Config.
134 135 136 |
# File 'lib/scout_apm/config.rb', line 134 def initialize() @overlays = Array() end |
Class Method Details
.with_file(file_path = nil, config = {}) ⇒ Object
Load up a config instance, attempting to load a yaml file. Allows a definite location if requested, or will attempt to load the default configuration file: APP_ROOT/config/scout_apm.yml
124 125 126 127 128 129 130 131 132 |
# File 'lib/scout_apm/config.rb', line 124 def self.with_file(file_path=nil, config={}) = [ ConfigEnvironment.new, ConfigFile.new(file_path, config), ConfigDefaults.new, ConfigNull.new, ] new() end |
.without_file ⇒ Object
Load up a config instance without attempting to load a file. Useful for bootstrapping.
112 113 114 115 116 117 118 119 |
# File 'lib/scout_apm/config.rb', line 112 def self.without_file = [ ConfigEnvironment.new, ConfigDefaults.new, ConfigNull.new, ] new() end |
Instance Method Details
#value(key) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/scout_apm/config.rb', line 138 def value(key) o = @overlays.detect{ || .has_key?(key) } raw_value = if o o.value(key) else # No overlay said it could handle this key, bail out with nil. nil end coercion = SETTING_COERCIONS.fetch(key, NullCoercion.new) coercion.coerce(raw_value) end |