Class: Bard::Backup::Destination

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/backup/destination.rb

Direct Known Subclasses

S3Destination, UploadDestination

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



5
6
7
# File 'lib/bard/backup/destination.rb', line 5

def config
  @config
end

Class Method Details

.build(config) ⇒ Object



6
7
8
9
# File 'lib/bard/backup/destination.rb', line 6

def self.build(config)
  klass = Bard::Backup.const_get("#{config[:type].to_s.capitalize}Destination")
  klass.new(config)
end

.resolve(destination_hashes = nil, now: nil) ⇒ Object

Normalizes destination config into built destinations: falls back to the configured destinations when none are given, and accepts a lone Hash or an Array. A now stamps every destination with one run timestamp (an explicit per-destination now still wins). Each destination resolves its own encryption key (see #encryption_key), so callers don’t have to inject it.



16
17
18
19
20
21
# File 'lib/bard/backup/destination.rb', line 16

def self.resolve(destination_hashes = nil, now: nil)
  hashes = destination_hashes || Bard::Config.current.backup.destinations
  hashes = hashes.is_a?(Hash) ? [hashes] : Array(hashes)
  hashes = hashes.map { |hash| { now:, **hash } } if now
  hashes.map { |hash| build(hash) }
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/bard/backup/destination.rb', line 23

def call
  raise NotImplementedError
end