Class: OneApm::Support::DottedHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/one_apm/support/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.



13
14
15
16
17
18
# File 'lib/one_apm/support/dotted_hash.rb', line 13

def initialize(hash, keep_nesting = false)
  merge!(hash) if keep_nesting
  merge!(dot_flattened(hash))

  DottedHash.symbolize(self)
end

Class Method Details

.symbolize(hash) ⇒ Object



7
8
9
10
11
# File 'lib/one_apm/support/dotted_hash.rb', line 7

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

Instance Method Details

#inspectObject



20
21
22
# File 'lib/one_apm/support/dotted_hash.rb', line 20

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

#to_hashObject



24
25
26
# File 'lib/one_apm/support/dotted_hash.rb', line 24

def to_hash
  {}.replace(self)
end