Sha256: ee8a7170182f52a4648005d28eca91bac96a809e326b29c6fba84b60b62db1a5
Contents?: true
Size: 991 Bytes
Versions: 14
Compression:
Stored size: 991 Bytes
Contents
# Unoptimized, highly inefficient in-memory datastore designed for use with specs. module Praxis::Mapper module Support class MemoryRepository attr_reader :collections def initialize clear! end def clear! @collections = Hash.new do |hash, collection_name| hash[collection_name] = Set.new end end 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 def insert(collection, *values) self.collection(collection).merge(*values) end # Retrieve all records for +collection+ matching all +conditions+. def all(collection, **conditions) self.collection(collection).select do |row| conditions.all? do |k,v| row[k] === v end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems