Sha256: 8800b4dc4c76255c4b00261ec86335e771f4012a6bb8ab8dba482bbd8ba215bd
Contents?: true
Size: 754 Bytes
Versions: 67
Compression:
Stored size: 754 Bytes
Contents
require 'forwardable' module Inferno module Repositories class InMemoryRepository extend Forwardable def_delegators 'self.class', :all, :all_by_id def insert(entity) all << entity entity 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 # @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
67 entries across 67 versions & 1 rubygems