class Inferno::Repositories::InMemoryRepository
Public Class Methods
all()
click to toggle source
# File lib/inferno/repositories/in_memory_repository.rb, line 23 def all @all ||= [] end
all_by_id()
click to toggle source
@api private
# File lib/inferno/repositories/in_memory_repository.rb, line 28 def all_by_id @all_by_id ||= {} @all_by_id.length == all.length ? @all_by_id : index_by_id end
index_by_id()
click to toggle source
# File lib/inferno/repositories/in_memory_repository.rb, line 33 def index_by_id @all_by_id = {} all.each { |klass| @all_by_id[klass.id] = klass } @all_by_id end
Public Instance Methods
exists?(id)
click to toggle source
# File lib/inferno/repositories/in_memory_repository.rb, line 18 def exists?(id) all_by_id.include? id end
find(id)
click to toggle source
# File lib/inferno/repositories/in_memory_repository.rb, line 14 def find(id) all_by_id[id.to_s] end
insert(klass)
click to toggle source
# File lib/inferno/repositories/in_memory_repository.rb, line 10 def insert(klass) all << klass end