module Tsuga::Adapter::Memory::Base::ClassMethods
Public Instance Methods
_records()
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 75 def _records @_records ||= {} end
collect_ids()
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 71 def collect_ids Set.new(_records.keys) end
delete_all()
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 63 def delete_all _records.replace Hash.new end
find_by_id(id)
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 55 def find_by_id(id) _records.fetch(id) { raise Tsuga::RecordNotFound }.clone end
find_each() { |clone| ... }
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 67 def find_each _records.dup.each_value { |r| yield r.clone } end
generate_id()
click to toggle source
FIXME: not thread safe. not sure we care, either.
# File lib/tsuga/adapter/memory/base.rb, line 50 def generate_id @_last_id ||= 0 @_last_id += 1 end
mass_create(records)
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 41 def mass_create(records) records.each(&:persist!) end
mass_update(records)
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 45 def mass_update(records) records.each(&:persist!) end
scoped(*filters)
click to toggle source
# File lib/tsuga/adapter/memory/base.rb, line 59 def scoped(*filters) Scope.new(self, filters) end