class Mutiny::Mutants::Storage

Attributes

store[RW]

Public Class Methods

new(mutant_directory: ".mutants", store: nil) click to toggle source
# File lib/mutiny/mutants/storage.rb, line 8
def initialize(mutant_directory: ".mutants", store: nil)
  @store = store || FileStore.new(mutant_directory: mutant_directory)
end

Public Instance Methods

load_for(subjects) click to toggle source
# File lib/mutiny/mutants/storage.rb, line 16
def load_for(subjects)
  mutants = store.load_all.map do |mutant_spec|
    mutant_spec[:subject] = resolve_subject(subjects, **mutant_spec[:subject])
    Mutant.new(**mutant_spec)
  end

  MutantSet.new(*mutants)
end
save(mutants) click to toggle source
# File lib/mutiny/mutants/storage.rb, line 12
def save(mutants)
  store.save_all(mutants)
end

Private Instance Methods

resolve_subject(subjects, name:, path:) click to toggle source
# File lib/mutiny/mutants/storage.rb, line 27
def resolve_subject(subjects, name:, path:)
  subjects.find { |subject| subject.name == name && subject.relative_path == path }
end