Module: Releaf::InstanceCache

Extended by:
ActiveSupport::Concern
Included in:
Builders::Page::MenuBuilder
Defined in:
lib/releaf/instance_cache.rb

Instance Method Summary collapse

Instance Method Details

#instance_cache(key) ⇒ Object


65
66
67
68
69
70
71
# File 'lib/releaf/instance_cache.rb', line 65

def instance_cache(key)
  if instance_cache_store.key?(key)
    instance_cache_store[key]
  else
    instance_cache_store[key] = yield
  end
end

#instance_cache_storeObject


57
58
59
# File 'lib/releaf/instance_cache.rb', line 57

def instance_cache_store
  @instance_cache_store ||= {}
end

#reset_instance_cacheObject


61
62
63
# File 'lib/releaf/instance_cache.rb', line 61

def reset_instance_cache
  @instance_cache_store = {}
end