class Praxis::Mapper::Support::MemoryRepository
Attributes
collections[R]
Public Class Methods
new()
click to toggle source
# File lib/praxis-mapper/support/memory_repository.rb, line 9 def initialize clear! end
Public Instance Methods
all(collection, **conditions)
click to toggle source
Retrieve all records for collection
matching all conditions
.
# File lib/praxis-mapper/support/memory_repository.rb, line 34 def all(collection, **conditions) self.collection(collection).select do |row| conditions.all? do |k,v| row[k] === v end end end
clear!()
click to toggle source
# File lib/praxis-mapper/support/memory_repository.rb, line 13 def clear! @collections = Hash.new do |hash, collection_name| hash[collection_name] = Set.new end end
collection(collection)
click to toggle source
# File lib/praxis-mapper/support/memory_repository.rb, line 19 def collection(collection) collection_name = if collection.respond_to?(:table_name) collection.table_name.to_sym else collection.to_sym end @collections[collection_name] end
insert(collection, *values)
click to toggle source
# File lib/praxis-mapper/support/memory_repository.rb, line 29 def insert(collection, *values) self.collection(collection).merge(*values) end