Class: Bard::Backup::Destination
- Inherits:
-
Struct
- Object
- Struct
- Bard::Backup::Destination
show all
- Defined in:
- lib/bard/backup/destination.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute 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).
15
16
17
18
19
20
|
# File 'lib/bard/backup/destination.rb', line 15
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
#call ⇒ Object
22
23
24
|
# File 'lib/bard/backup/destination.rb', line 22
def call
raise NotImplementedError
end
|
#encryption_key ⇒ Object
26
27
28
|
# File 'lib/bard/backup/destination.rb', line 26
def encryption_key
config[:encryption_key]
end
|