Class: Belt::CLI::BackupConfig::BackupDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/belt/cli/backup_config.rb

Overview

DSL for the backups block

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ BackupDSL

Returns a new instance of BackupDSL.



87
88
89
# File 'lib/belt/cli/backup_config.rb', line 87

def initialize(config)
  @config = config
end

Instance Method Details

#cognito(*exports) ⇒ Object



100
101
102
# File 'lib/belt/cli/backup_config.rb', line 100

def cognito(*exports)
  @config.instance_variable_set(:@cognito_exports, exports.flatten.map(&:to_sym))
end

#dynamodb(scope = :all) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/belt/cli/backup_config.rb', line 91

def dynamodb(scope = :all)
  if scope == :all
    @config.instance_variable_set(:@dynamodb_tables, :all)
  else
    tables = Array(scope)
    @config.instance_variable_set(:@dynamodb_tables, tables.map(&:to_s))
  end
end

#retention(opts = {}) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/belt/cli/backup_config.rb', line 108

def retention(opts = {})
  current = @config.instance_variable_get(:@retention)
  merged = current.merge(opts.transform_keys(&:to_sym))

  # Convert duration objects (90.days) to integer days
  merged.transform_values! do |v|
    v.respond_to?(:to_i) ? v.to_i : v
  end

  @config.instance_variable_set(:@retention, merged)
end

#s3(*buckets) ⇒ Object



104
105
106
# File 'lib/belt/cli/backup_config.rb', line 104

def s3(*buckets)
  @config.instance_variable_set(:@s3_buckets, buckets.flatten.map(&:to_sym))
end