lib/recurly/resource.rb in recurly-2.4.12 vs lib/recurly/resource.rb in recurly-2.5.0
- old
+ new
@@ -320,12 +320,13 @@
if uuid.nil?
# Should we raise an ArgumentError, instead?
raise NotFound, "can't find a record with nil identifier"
end
+ uri = uuid =~ /^http/ ? uuid : member_path(uuid)
begin
- from_response API.get(member_path(uuid), {}, options)
+ from_response API.get(uri, {}, options)
rescue API::NotFound => e
raise NotFound, e.description
end
end
@@ -594,16 +595,13 @@
def reload response = nil
if response
return if response.body.to_s.length.zero?
fresh = self.class.from_response response
else
- options = {:etag => (etag unless changed?)}
- fresh = if @href
- self.class.from_response API.get(@href, {}, options)
- else
- self.class.find(to_param, options)
- end
+ fresh = self.class.find(
+ @href || to_param, :etag => (etag unless changed?)
+ )
end
fresh and copy_from fresh
persist! true
self
rescue API::NotModified
@@ -917,17 +915,13 @@
# account.destroy # => true
# account.destroy # => false (already destroyed)
# race_condition.destroy # raises Recurly::Resource::NotFound
def destroy
return false unless persisted?
- @response = API.delete destroy_uri
+ @response = API.delete uri
@destroyed = true
rescue API::NotFound => e
raise NotFound, e.description
- end
-
- def destroy_uri
- uri
end
def signable_attributes
Hash[xml_keys.map { |key| [key, self[key]] }]
end