Class: Inferno::Repositories::InMemoryRepository
- Inherits:
-
Object
- Object
- Inferno::Repositories::InMemoryRepository
show all
- Extended by:
- Forwardable
- Defined in:
- lib/inferno/repositories/in_memory_repository.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.all ⇒ Object
24
25
26
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 24
def all
@all ||= []
end
|
.index_by_id ⇒ Object
34
35
36
37
38
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 34
def index_by_id
@all_by_id = {}
all.each { |klass| @all_by_id[klass.id] = klass }
@all_by_id
end
|
Instance Method Details
#exists?(id) ⇒ Boolean
19
20
21
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 19
def exists?(id)
all_by_id.include? id
end
|
#find(id) ⇒ Object
15
16
17
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 15
def find(id)
all_by_id[id.to_s]
end
|
#insert(entity) ⇒ Object
10
11
12
13
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 10
def insert(entity)
all << entity
entity
end
|