Class: VCloudCloud::Cache
- Inherits:
-
Object
- Object
- VCloudCloud::Cache
- Defined in:
- lib/cloud/vcloud/cache.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #get(id, &block) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
3 4 5 |
# File 'lib/cloud/vcloud/cache.rb', line 3 def initialize @objects = {} end |
Instance Method Details
#clear ⇒ Object
16 17 18 |
# File 'lib/cloud/vcloud/cache.rb', line 16 def clear @objects = {} end |
#get(id, &block) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/cloud/vcloud/cache.rb', line 7 def get(id, &block) object = @objects[id] unless object object = block.call id @objects[id] = object end object end |