Class: Snapsync::DefaultSyncPolicy

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

Overview

Default synchronization policy

Synchronization policy objects are used by the synchronization passes to decide which snapshots to copy and which to not copy. They have to provide #filter_snapshots.

This default policy is to copy everything but the snapsync-created synchronization points that are not involving the current target

Direct Known Subclasses

TimelineSyncPolicy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_config(config) ⇒ Object



16
17
18
# File 'lib/snapsync/default_sync_policy.rb', line 16

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

Parameters:

  • target (#uuid)

    the target object

  • the (Array<Snapshot>)

    snapshot candidates

Returns:

  • (Array<Snapshot>)

    the snapshots that should be copied



30
31
32
33
# File 'lib/snapsync/default_sync_policy.rb', line 30

def filter_snapshots(snapshots)
    # Filter out any snapsync-generated snapshot
    snapshots.find_all { |s| !s.synchronization_point? }
end

#pretty_print(pp) ⇒ Object

Pretty prints this policy

This is used by the CLI to give information about a target to the user



38
39
40
# File 'lib/snapsync/default_sync_policy.rb', line 38

def pretty_print(pp)
    pp.text "default policy"
end

#to_configObject



20
21
22
# File 'lib/snapsync/default_sync_policy.rb', line 20

def to_config
    Array.new
end