lib/social_profile/people/vkontakte.rb in social_profile-0.1.1 vs lib/social_profile/people/vkontakte.rb in social_profile-0.1.2
- old
+ new
@@ -25,12 +25,12 @@
end
end
class Album
- def initialize(hash, target)
- @hash = Array.wrap(hash["response"]).first || {}
+ def initialize(response, target)
+ @hash = normalize_hash(response)
@target = target
end
def http_client
@http_client ||= ::HTTPClient.new(:agent_name => 'SocialProfile robot/0.1')
@@ -81,9 +81,14 @@
if server && server['response']
server['response']['upload_url']
else
nil
end
+ end
+
+ def normalize_hash(hash)
+ response = (hash && hash["response"] ? Array.wrap(hash["response"]).first : hash)
+ response || {}
end
end
end
end
\ No newline at end of file