Class: Array

Inherits:
Object show all
Defined in:
lib/switchvox/array.rb

Overview

A fancy way of iterating over an array and converting hashes to objects

Instance Method Summary collapse

Instance Method Details

#to_objObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/switchvox/array.rb', line 3

def to_obj
  # Make a deep copy of the array
  a = Marshal.load(Marshal.dump(self))
  a.each do |i|
    case i.class.to_s
      when "Hash" then i = i.to_obj
      when "Array" then i = i.to_obj
    end
  end
  a
end