Class: Transdifflation::HashSymbolTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/transdifflation/utilities.rb

Overview

Class used to convert all keys in a hash (included sub-hashes) in symbols

Instance Method Summary collapse

Instance Method Details

#symbolize(hash) ⇒ Object

Convert keys



8
9
10
11
12
13
14
15
16
17
# File 'lib/transdifflation/utilities.rb', line 8

def symbolize(hash)
  hash = hash.inject({}) { |memo,(k,v)| 
      if(v.instance_of? Hash)
         v = symbolize(v)
      end 
      memo[k.to_sym] = v
      memo
  }
  hash
end