Class: NewRelic::Agent::Configuration::DottedHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/new_relic/agent/configuration/dotted_hash.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, keep_nesting = false) ⇒ DottedHash

Returns a new instance of DottedHash.



9
10
11
12
13
14
15
16
17
# File 'lib/new_relic/agent/configuration/dotted_hash.rb', line 9

def initialize(hash, keep_nesting = false)
  # Add the hash keys to our collection explicitly so they survive the
  # dot flattening.  This is typical for full config source instances,
  # but not for uses of DottedHash serializing for transmission.
  self.merge!(hash) if keep_nesting

  self.merge!(dot_flattened(hash))
  DottedHash.symbolize(self)
end

Class Method Details

.symbolize(hash) ⇒ Object



27
28
29
30
31
# File 'lib/new_relic/agent/configuration/dotted_hash.rb', line 27

def self.symbolize(hash)
  hash.keys.each do |key|
    hash[key.to_sym] = hash.delete(key)
  end
end

Instance Method Details

#inspectObject



19
20
21
# File 'lib/new_relic/agent/configuration/dotted_hash.rb', line 19

def inspect
  "#<#{self.class.name}:#{object_id} #{super}>"
end

#to_hashObject



23
24
25
# File 'lib/new_relic/agent/configuration/dotted_hash.rb', line 23

def to_hash
  {}.replace(self)
end