Class: Bard::Backup::Destination
- Inherits:
-
Struct
- Object
- Struct
- Bard::Backup::Destination
- Defined in:
- lib/bard/backup/destination.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
- .build(config) ⇒ Object
-
.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.
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). 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
#call ⇒ Object
23 24 25 |
# File 'lib/bard/backup/destination.rb', line 23 def call raise NotImplementedError end |