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
28
29
30
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 28
def all
@all ||= []
end
|
Instance Method Details
#exists?(id) ⇒ Boolean
23
24
25
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 23
def exists?(id)
all_by_id.key?(id.to_s)
end
|
#find(id) ⇒ Object
19
20
21
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 19
def find(id)
all_by_id[id.to_s]
end
|
#insert(entity) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/inferno/repositories/in_memory_repository.rb', line 11
def insert(entity)
raise Exceptions::DuplicateEntityIdException, entity.id if exists?(entity.id)
all << entity
all_by_id[entity.id.to_s] = entity
entity
end
|