Class: SourceMonitor::Dashboard::Queries::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/dashboard/queries.rb

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



130
131
132
# File 'lib/source_monitor/dashboard/queries.rb', line 130

def initialize
  @store = {}
end

Instance Method Details

#fetch(key) ⇒ Object



134
135
136
137
138
139
140
# File 'lib/source_monitor/dashboard/queries.rb', line 134

def fetch(key)
  if store.key?(key)
    store.fetch(key)
  else
    store[key] = yield
  end
end