6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/bard/backup/database.rb', line 6
def self.create!(destination_hashes = nil, **config)
if destination_hashes.nil? && !config.empty?
destination_hashes = [config]
end
bard_config = defined?(Bard::Config) ? Bard::Config.current : nil
destination_hashes ||= bard_config&.backup&.destinations || []
destinations = if destination_hashes.is_a?(Hash)
[destination_hashes]
else
Array(destination_hashes)
end
encryption_key = bard_config&.respond_to?(:encryption_key) ? bard_config.encryption_key : nil
if encryption_key
destinations = destinations.map { |h| { encryption_key: encryption_key, **h } }
end
result = nil
destinations.each do |hash|
result = Backup::Destination.build(hash).call
end
result
end
|