Class: Ezframe::DB::Cache

Inherits:
Object show all
Defined in:
lib/ezframe/database.rb

Class Method Summary collapse

Class Method Details

.[](table) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/ezframe/database.rb', line 165

def [](table)
  @store ||= {}
  dataset = DB.dataset(table.to_sym)
  # EzLog.debug("DB::Cache: #{table}")
  unless @store[table.to_sym]
    data_a = dataset.where(deleted_at: nil).all
    h = {}
    data_a.each {|data| h[data[:id]] = data }
    @store[table.to_sym] = h
  end
  # EzLog.debug(@store[table.to_sym])
  return @store[table.to_sym]
end