Sha256: 214d084d7b54e4797e2d596f43020a19a61230006553e4c6d7b57ca4700dc2fb
Contents?: true
Size: 1.29 KB
Versions: 9
Compression:
Stored size: 1.29 KB
Contents
require 'rom/repository' require 'rom/memory/storage' require 'rom/memory/commands' module ROM module Memory # In-memory repository interface # # @example # repository = ROM::Memory::Repository.new # repository.dataset(:users) # repository[:users].insert(name: 'Jane') # # @api public class Repository < ROM::Repository # @return [Object] default logger # # @api public attr_reader :logger # @api private def initialize @connection = Storage.new end # Set default logger for the repository # # @param [Object] logger object # # @api public def use_logger(logger) @logger = logger end # Register a dataset in the repository # # If dataset already exists it will be returned # # @return [Dataset] # # @api public def dataset(name) self[name] || connection.create_dataset(name) end # @see ROM::Repository#dataset? def dataset?(name) connection.key?(name) end # Return dataset with the given name # # @param (see ROM::Repository#[]) # @return [Memory::Dataset] # # @api public def [](name) connection[name] end end end end
Version data entries
9 entries across 9 versions & 1 rubygems