Method: Fog::OpenStack::Identity::V3::Domains#all

Defined in:
lib/fog/openstack/identity/v3/models/domains.rb

#all(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/identity/v3/models/domains.rb', line 11

def all(options = {})
  if service.openstack_cache_ttl > 0
    cached_domain, expires = Fog::OpenStack::Identity::V3::Domain.cache[{:token   => service.auth_token,
                                                                         :options => options}]
    return cached_domain if cached_domain && expires > Time.now
  end

  domain_to_cache = load_response(service.list_domains(options), 'domains')
  if service.openstack_cache_ttl > 0
    cache = Fog::OpenStack::Identity::V3::Domain.cache
    cache[{:token => service.auth_token, :options => options}] = [domain_to_cache,
                                                                  Time.now + service.openstack_cache_ttl]
    Fog::OpenStack::Identity::V3::Domain.cache = cache
  end
  domain_to_cache
end