Class: Madeleine::Snapshotter

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(directory_name, marshaller) ⇒ Snapshotter

Returns a new instance of Snapshotter.



408
409
410
# File 'lib/madeleine.rb', line 408

def initialize(directory_name, marshaller)
  @directory_name, @marshaller = directory_name, marshaller
end

Instance Method Details

#take(system) ⇒ Object



412
413
414
415
416
417
418
419
420
421
# File 'lib/madeleine.rb', line 412

def take(system)
  numbered_file = SnapshotFile.next(@directory_name)
  name = numbered_file.name
  open("#{name}.tmp", 'wb') do |snapshot|
    @marshaller.dump(system, snapshot)
    snapshot.flush
    snapshot.fsync
  end
  File.rename("#{name}.tmp", name)
end