Class: AWS::Core::ResourceCache
- Inherits:
-
Object
- Object
- AWS::Core::ResourceCache
- Defined in:
- lib/aws/core/resource_cache.rb
Instance Method Summary collapse
- #cached?(key, attribute) ⇒ Boolean
- #get(key, attribute) ⇒ Object
-
#initialize ⇒ ResourceCache
constructor
A new instance of ResourceCache.
- #store(key, attributes) ⇒ Object
Constructor Details
#initialize ⇒ ResourceCache
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
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 |