Class: Space::Architect::Research::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/space_architect/research/registry.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Registry

Returns a new instance of Registry.



9
10
11
# File 'lib/space_architect/research/registry.rb', line 9

def initialize(path)
  @path = Pathname.new(path)
end

Instance Method Details

#add(run) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/space_architect/research/registry.rb', line 13

def add(run)
  runs = load_runs
  runs.reject! { |r| r["id"] == run.id }
  runs << serialize(run)
  write(runs)
  run
end

#allObject



21
22
23
# File 'lib/space_architect/research/registry.rb', line 21

def all
  load_runs.map { |h| deserialize(h) }
end

#find(id) ⇒ Object



25
26
27
# File 'lib/space_architect/research/registry.rb', line 25

def find(id)
  load_runs.find { |h| h["id"] == id }.then { |h| h ? deserialize(h) : nil }
end