Module: Hashtostruct::ArrayToObject

Defined in:
lib/hashtostruct.rb

Instance Method Summary collapse

Instance Method Details

#to_objObject

iterates through the array, converting each string element to a native element if possible and returns it



61
62
63
64
65
66
67
68
69
# File 'lib/hashtostruct.rb', line 61

def to_obj
  self.inject([]) do |res,elem|
    res << if elem.is_a?(String) or elem.is_a?(Array) or elem.is_a?(Hash)
             elem.to_obj
           else
             elem
           end
  end
end