Class: Mutiny::Mutants::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/mutiny/mutants/storage.rb,
lib/mutiny/mutants/storage/path.rb,
lib/mutiny/mutants/storage/file_store.rb,
lib/mutiny/mutants/storage/mutant_file.rb,
lib/mutiny/mutants/storage/mutant_file_name.rb,
lib/mutiny/mutants/storage/mutant_file_contents.rb

Defined Under Namespace

Classes: FileStore, MutantFile, MutantFileContents, MutantFileName, Path

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mutant_directory: ".mutants", store: nil) ⇒ Storage

Returns a new instance of Storage.



8
9
10
# File 'lib/mutiny/mutants/storage.rb', line 8

def initialize(mutant_directory: ".mutants", store: nil)
  @store = store || FileStore.new(mutant_directory: mutant_directory)
end

Instance Attribute Details

#storeObject

Returns the value of attribute store.



6
7
8
# File 'lib/mutiny/mutants/storage.rb', line 6

def store
  @store
end

Instance Method Details

#loadObject



16
17
18
19
20
21
22
23
24
# File 'lib/mutiny/mutants/storage.rb', line 16

def load
  mutants = store.load_all.map do |mutant_specification|
    subject = Subjects::Subject.new(**mutant_specification[:subject])
    mutant_specification[:subject] = subject
    Mutant.new(**mutant_specification)
  end

  MutantSet.new(*mutants)
end

#save(mutants) ⇒ Object



12
13
14
# File 'lib/mutiny/mutants/storage.rb', line 12

def save(mutants)
  store.save_all(mutants)
end