Class: Holoserve::Tool::Hash::KeySymbolizer

Inherits:
Object
  • Object
show all
Defined in:
lib/holoserve/tool/hash/key_symbolizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash_or_array) ⇒ KeySymbolizer

Returns a new instance of KeySymbolizer.



4
5
6
# File 'lib/holoserve/tool/hash/key_symbolizer.rb', line 4

def initialize(hash_or_array)
  @hash_or_array = hash_or_array
end

Instance Method Details

#hashObject



8
9
10
11
12
13
14
15
16
# File 'lib/holoserve/tool/hash/key_symbolizer.rb', line 8

def hash
  if @hash_or_array.is_a?(Hash)
    symbolize_keys @hash_or_array
  elsif @hash_or_array.is_a?(Array)
    symbolize_keys_of_all @hash_or_array
  else
    @hash_or_array
  end
end