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.



395
396
397
# File 'lib/madeleine.rb', line 395

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

Instance Method Details

#take(system) ⇒ Object



399
400
401
402
403
404
405
406
407
408
# File 'lib/madeleine.rb', line 399

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