lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-3.6.6.147 vs lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-3.6.7.152

- old
+ new

@@ -1,22 +1,22 @@ # encoding: utf-8 # This file is distributed under New Relic's license terms. # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details. require 'forwardable' -require 'new_relic/agent/configuration/defaults' require 'new_relic/agent/configuration/mask_defaults' require 'new_relic/agent/configuration/yaml_source' +require 'new_relic/agent/configuration/default_source' require 'new_relic/agent/configuration/server_source' require 'new_relic/agent/configuration/environment_source' module NewRelic module Agent module Configuration class Manager extend Forwardable - def_delegators :@cache, :[], :has_key? + def_delegators :@cache, :[], :has_key?, :keys attr_reader :config_stack, :stripped_exceptions_whitelist def initialize reset_to_defaults @callbacks = Hash.new {|hash,key| hash[key] = [] } @@ -51,13 +51,13 @@ invoke_callbacks(:remove, source) log_config(:remove, source) 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) + index = @config_stack.map{|s| s.class}.index(source.class) + @config_stack.delete_at(index) if index + apply_config(source, index || level) end def source(key) @config_stack.each do |config| if config.respond_to?(key.to_sym) || config.has_key?(key.to_sym) @@ -109,21 +109,21 @@ @config_stack.any? {|s| s.is_a?(ServerSource)} end def flattened @config_stack.reverse.inject({}) do |flat,layer| - thawed_layer = layer.dup + thawed_layer = layer.to_hash.dup thawed_layer.each do |k,v| begin thawed_layer[k] = instance_eval(&v) if v.respond_to?(:call) rescue => e ::NewRelic::Agent.logger.debug("#{e.class.name} : #{e.message} - when accessing config key #{k}") thawed_layer[k] = nil end thawed_layer.delete(:config) end - flat.merge(thawed_layer) + flat.merge(thawed_layer.to_hash) end end def apply_mask(hash) MASK_DEFAULTS. \ @@ -144,10 +144,10 @@ end end # Generally only useful during initial construction and tests def reset_to_defaults - @config_stack = [ EnvironmentSource.new, DEFAULTS ] + @config_stack = [ EnvironmentSource.new, DefaultSource.new ] reset_cache end def reset_cache @cache = Hash.new {|hash,key| hash[key] = self.fetch(key) }