Sha256: b68d4ca202f57218b07e9fff1b7279a7c7a1a8c6ce6a5d95b2368f71a91d15d3
Contents?: true
Size: 1.72 KB
Versions: 6
Compression:
Stored size: 1.72 KB
Contents
module SnapshotArchive module Archives class Builder def self.call(dir:, stores:, id:) new(dir, stores, id).call end attr_reader :dir, :stores, :id def initialize(dir, stores, id) @dir = dir @stores = stores @id = id end def call stores_metadata = ( stores .map { |name, store| File .join(dir, name) .tap { FileUtils.mkdir(_1) } .then { store.backup(dir: _1, id: id, name: name)&.merge(type: name) } } .compact ) { stores: stores_metadata } end end class Restore def self.call(metadata) new(metadata).call end attr_reader :metadata def initialize(metadata) @metadata = metadata end def call metadata.fetch("stores").reverse.each do |store_metadata| store = Cfg.instance.store(store_metadata.fetch("type")) store.restore(metadata: store_metadata) end end end class Delete def self.call(metadata) new(metadata).call end attr_reader :metadata def initialize(metadata) @metadata = metadata end def call metadata.fetch("stores").each do |store_metadata| store = Cfg.instance.store(store_metadata.fetch("type")) if store.respond_to?(:delete) store.delete(metadata: store_metadata) end end end end class Presenter def self.call(metadata) new(metadata).call end attr_reader :metadata def initialize(metadata) @metadata = metadata end end end end
Version data entries
6 entries across 6 versions & 1 rubygems