Class: VCloudCloud::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud/vcloud/cache.rb

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



3
4
5
# File 'lib/cloud/vcloud/cache.rb', line 3

def initialize
  @objects = {}
end

Instance Method Details

#clearObject



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