Class: MicroManager::Persistence

Inherits:
Object
  • Object
show all
Defined in:
lib/micro_manager/persistence.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Persistence

Returns a new instance of Persistence.



7
8
9
# File 'lib/micro_manager/persistence.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#recover(serializer: YAML, reader: File) ⇒ Object



17
18
19
20
# File 'lib/micro_manager/persistence.rb', line 17

def recover(serializer: YAML, reader: File)
  content = reader.read(config.save_location)
  serializer.load(content)
end

#save(schedule, serializer: YAML, writer: File) ⇒ Object



11
12
13
14
15
# File 'lib/micro_manager/persistence.rb', line 11

def save(schedule, serializer: YAML, writer: File)
  file = config.save_location
  serialized_schedule = serializer.dump(schedule)
  writer.write(file, serialized_schedule)
end