lib/fog/openstack/models/identity/tenants.rb in fog-1.6.0 vs lib/fog/openstack/models/identity/tenants.rb in fog-1.7.0
- old
+ new
@@ -10,12 +10,14 @@
def all
load(connection.list_tenants.body['tenants'])
end
def find_by_id(id)
- self.find {|tenant| tenant.id == id} ||
- Fog::Identity::OpenStack::Tenant.new(
- connection.get_tenant(id).body['tenant'])
+ cached_tenant = self.find {|tenant| tenant.id == id}
+ return cached_tenant if cached_tenant
+ tenant_hash = connection.get_tenant(id).body['tenant']
+ Fog::Identity::OpenStack::Tenant.new(
+ tenant_hash.merge(:connection => connection))
end
def destroy(id)
tenant = self.find_by_id(id)
tenant.destroy