1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Make Model#reload more resilient against errors.

Connection errors had the behavior of failing catastrophically, which had
some rather unpleasant implications for things like Model#wait_for, which
implicitly reload repeatedly without any protection.

This change may be better suited to special cases (e.g. Model#wait_for).
This commit is contained in:
Pieter van de Bruggen 2011-04-13 10:47:30 -07:00 committed by geemus
parent e71895f1a4
commit 331d58dabf

View file

@ -25,11 +25,16 @@ module Fog
def reload
requires :identity
if data = collection.get(identity)
new_attributes = data.attributes
merge_attributes(new_attributes)
self
return unless data = begin
collection.get(identity)
rescue Excon::Errors::SocketError
nil
end
new_attributes = data.attributes
merge_attributes(new_attributes)
self
end
def to_json