Class: Rod::Rest::ProxyCache
- Inherits:
-
Object
- Object
- Rod::Rest::ProxyCache
- Defined in:
- lib/rod/rest/proxy_cache.rb
Overview
Cache used to store proxy objects.
Instance Method Summary collapse
-
#[](description) ⇒ Object
Returns the object stored in the cache.
-
#has_key?(description) ⇒ Boolean
Returns true if the described object is in the cache.
-
#initialize ⇒ ProxyCache
constructor
Initializes empty cache.
-
#store(object) ⇒ Object
Store the
object
in the cache.
Constructor Details
#initialize ⇒ ProxyCache
Initializes empty cache.
8 9 10 |
# File 'lib/rod/rest/proxy_cache.rb', line 8 def initialize() @cache_implementation = {} end |
Instance Method Details
#[](description) ⇒ Object
Returns the object stored in the cache. Raises CacheMissed exception if the result is nil.
20 21 22 23 24 25 26 27 |
# File 'lib/rod/rest/proxy_cache.rb', line 20 def [](description) check_description(description) begin @cache_implementation.fetch(description_signature(description)) rescue KeyError raise CacheMissed.new((description)) end end |
#has_key?(description) ⇒ Boolean
Returns true if the described object is in the cache.
13 14 15 16 |
# File 'lib/rod/rest/proxy_cache.rb', line 13 def has_key?(description) check_description(description) @cache_implementation.has_key?(description_signature(description)) end |
#store(object) ⇒ Object
Store the object
in the cache.
30 31 32 33 |
# File 'lib/rod/rest/proxy_cache.rb', line 30 def store(object) check_object(object) @cache_implementation[description_signature(rod_id: object.rod_id,type: object.type)] = object end |