Class: Inferno::Repositories::RunnableRepository

Inherits:
InMemoryRepository show all
Defined in:
lib/inferno/repositories/runnable_repository.rb

Direct Known Subclasses

TestGroups, TestSuites, Tests

Instance Method Summary collapse

Methods inherited from InMemoryRepository

all, #exists?, #find

Instance Method Details

#insert(entity) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/inferno/repositories/runnable_repository.rb', line 6

def insert(entity)
  raise Exceptions::DuplicateEntityIdException, entity.id if exists?(entity.id)

  # Safety check to prevent rare database_id collisions from overwriting entries
  if exists?(entity.database_id) && entity.database_id.to_s != entity.id.to_s
    raise Exceptions::DuplicateEntityIdException,
          "database_id: `#{entity.database_id}` generated from original id: `#{entity.id}`"
  end

  all << entity
  all_by_id[entity.id.to_s] = entity
  all_by_id[entity.database_id.to_s] = entity unless entity.database_id.to_s == entity.id.to_s

  entity
end

#remove(entity) ⇒ Object



22
23
24
25
26
# File 'lib/inferno/repositories/runnable_repository.rb', line 22

def remove(entity)
  super

  all_by_id.delete(entity.database_id.to_s) unless entity.database_id.to_s == entity.id.to_s
end