Class: Pumi::StoreCache

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/pumi/store_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_store) ⇒ StoreCache

Returns a new instance of StoreCache.



7
8
9
10
11
# File 'lib/pumi/store_cache.rb', line 7

def initialize(data_store)
  super(data_store)

  @cached = {}
end

Instance Attribute Details

#cachedObject (readonly)

Returns the value of attribute cached.



5
6
7
# File 'lib/pumi/store_cache.rb', line 5

def cached
  @cached
end

Instance Method Details

#load(type, *args) ⇒ Object



13
14
15
16
17
# File 'lib/pumi/store_cache.rb', line 13

def load(type, *args)
  cached.fetch(type) do
    cached[type] = super
  end
end