Class: Snapsync::SyncLastPolicy

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

Overview

A simple policy that synchronizes only the last snapshot (that is, snapsync’s own synchronization point)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_config(config) ⇒ Object



5
6
7
# File 'lib/snapsync/sync_last_policy.rb', line 5

def self.from_config(config)
    new
end

Instance Method Details

#filter_snapshots(snapshots) ⇒ Array<Snapshot>

Returns the snapshots that should be synchronized according to this policy



18
19
20
21
22
# File 'lib/snapsync/sync_last_policy.rb', line 18

def filter_snapshots(snapshots)
    last = snapshots.sort_by(&:num).reverse.
        find { |s| !s.synchronization_point? }
    [last]
end

#pretty_print(pp) ⇒ Object



13
14
15
# File 'lib/snapsync/sync_last_policy.rb', line 13

def pretty_print(pp)
    pp.text "will keep only the latest snapshot"
end

#to_configObject



9
10
11
# File 'lib/snapsync/sync_last_policy.rb', line 9

def to_config
    Array.new
end