Class: Mountebank::Helper
- Inherits:
-
Object
- Object
- Mountebank::Helper
- Defined in:
- lib/mountebank/helper.rb
Class Method Summary collapse
-
.symbolize(obj) ⇒ Object
Convert Ruby Hash keys into symbols Source: gist.github.com/Integralist/9503099.
Class Method Details
.symbolize(obj) ⇒ Object
Convert Ruby Hash keys into symbols Source: gist.github.com/Integralist/9503099
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mountebank/helper.rb', line 7 def self.symbolize(obj) return obj.reduce({}) do |memo, (k, v)| memo.tap { |m| m[k.to_sym] = symbolize(v) } end if obj.is_a? Hash return obj.reduce([]) do |memo, v| memo << symbolize(v); memo end if obj.is_a? Array obj end |