lib/bearcat/api_array.rb in bearcat-1.3.52 vs lib/bearcat/api_array.rb in bearcat-1.3.53
- old
+ new
@@ -8,14 +8,24 @@
if response.body.is_a?(Array)
ApiArray.new(response, api_client)
elsif key = array_key(response)
ApiArray.new(response, api_client, key)
else
- response.body
+ make_indifferent(response.body)
end
end
+ def self.make_indifferent(thing)
+ if thing.is_a?(Array)
+ thing.map { |v| make_indifferent(v) }
+ elsif thing.is_a?(Hash)
+ thing.with_indifferent_access
+ else
+ thing
+ end
+ end
+
def initialize(response, api_client, array_key = nil)
@api_client = api_client
@array_key = array_key
@page_count = 100
case response.status
@@ -170,13 +180,12 @@
key
end
def process_body(response)
if response.body.is_a?(Array)
- response.body
+ ApiArray.make_indifferent(response.body)
elsif response.body.is_a?(Hash) && @array_key
- response.body[@array_key]
+ ApiArray.make_indifferent(response.body[@array_key])
end
end
-
end
end