Class: SnapshotArchive::Archives::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/snapshot_archive/archives.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, stores, id) ⇒ Builder

Returns a new instance of Builder.



9
10
11
12
13
# File 'lib/snapshot_archive/archives.rb', line 9

def initialize(dir, stores, id)
  @dir = dir
  @stores = stores
  @id = id
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



8
9
10
# File 'lib/snapshot_archive/archives.rb', line 8

def dir
  @dir
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/snapshot_archive/archives.rb', line 8

def id
  @id
end

#storesObject (readonly)

Returns the value of attribute stores.



8
9
10
# File 'lib/snapshot_archive/archives.rb', line 8

def stores
  @stores
end

Class Method Details

.call(dir:, stores:, id:) ⇒ Object



4
5
6
# File 'lib/snapshot_archive/archives.rb', line 4

def self.call(dir:, stores:, id:)
  new(dir, stores, id).call
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/snapshot_archive/archives.rb', line 15

def call
   = (
    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: 
  }
end