Class: AWS::Core::ResourceCache

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/core/resource_cache.rb

Instance Method Summary collapse

Constructor Details

#initializeResourceCache

Returns a new instance of ResourceCache.



20
21
22
# File 'lib/aws/core/resource_cache.rb', line 20

def initialize
  @cache = {}
end

Instance Method Details

#cached?(key, attribute) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/aws/core/resource_cache.rb', line 28

def cached?(key, attribute)
  attributes = @cache[key] and attributes.has_key?(attribute)
end

#get(key, attribute) ⇒ Object



32
33
34
35
36
# File 'lib/aws/core/resource_cache.rb', line 32

def get(key, attribute)
  raise "No cached value for attribute :#{attribute} of #{key}" unless
    cached?(key, attribute)
  @cache[key][attribute]
end

#store(key, attributes) ⇒ Object



24
25
26
# File 'lib/aws/core/resource_cache.rb', line 24

def store(key, attributes)
  (@cache[key] ||= {}).merge!(attributes)
end