Sha256: 3a337ba750f74c264197c9da0e1445a3c70656c433d9a3502813b52d3befde71
Contents?: true
Size: 741 Bytes
Versions: 6
Compression:
Stored size: 741 Bytes
Contents
require 'forwardable' module Inferno module Repositories class InMemoryRepository extend Forwardable def_delegators 'self.class', :all, :all_by_id def insert(klass) all << klass end def find(id) all_by_id[id.to_s] end def exists?(id) all_by_id.include? id end class << self def all @all ||= [] end # @api private def all_by_id @all_by_id ||= {} @all_by_id.length == all.length ? @all_by_id : index_by_id end def index_by_id @all_by_id = {} all.each { |klass| @all_by_id[klass.id] = klass } @all_by_id end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems