Method: EasyPost::Util.objects_to_ids

Defined in:
lib/easypost/util.rb

.objects_to_ids(obj) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/easypost/util.rb', line 3

def self.objects_to_ids(obj)
  case obj
  when Resource
    return {:id => obj.id}
  when Hash
    result = {}
    obj.each { |k, v| result[k] = objects_to_ids(v) unless v.nil? }
    return result
  when Array
    return obj.map { |v| objects_to_ids(v) }
  else
    return obj
  end
end