lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-3.4.2.beta1 vs lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-3.4.2
- old
+ new
@@ -13,15 +13,10 @@
attr_reader :config_stack # mainly for testing
def initialize
@config_stack = [ EnvironmentSource.new, DEFAULTS ]
@cache = Hash.new {|hash,key| hash[key] = self.fetch(key) }
-
- # letting Control handle this for now
-# yaml_config = YamlSource.new("#{NewRelic::Control.instance.root}/#{self['config_path']}",
-# NewRelic::Control.instance.env)
-# apply_config(yaml_config, 1) if yaml_config
end
def apply_config(source, level=0)
@config_stack.insert(level, source.freeze)
expire_cache
@@ -32,9 +27,15 @@
@config_stack.delete_if {|c| yield c }
else
@config_stack.delete(source)
end
expire_cache
+ end
+
+ def replace_or_add_config(source, level=0)
+ idx = @config_stack.map{|s| s.class}.index(source.class)
+ @config_stack.delete_at(idx) if idx
+ apply_config(source, idx || level)
end
def source(key)
@config_stack.each do |config|
if config.respond_to?(key.to_sym) || config.has_key?(key.to_sym)