Class: D13n::Configuration::DottedHash

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



3
4
5
6
7
8
# File 'lib/d13n/configuration/dotted_hash.rb', line 3

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

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

Class Method Details

.symbolize(hash) ⇒ Object



18
19
20
21
22
# File 'lib/d13n/configuration/dotted_hash.rb', line 18

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

Instance Method Details

#inspectObject



10
11
12
# File 'lib/d13n/configuration/dotted_hash.rb', line 10

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

#to_hashObject



14
15
16
# File 'lib/d13n/configuration/dotted_hash.rb', line 14

def to_hash
  {}.replace(self)
end