class Backup::Storages

Storage based on Amazon S3

Base stuff for storages

Storage based on some directory in local filesystem

Public Class Methods

new() click to toggle source
# File lib/backup-agent/storages.rb, line 9
def initialize
  @groups = {}
end

Public Instance Methods

[](pair) click to toggle source
# File lib/backup-agent/storages.rb, line 13
def [](pair)
  @groups.fetch(pair.keys[0]).fetch(pair.values[0])
end
amazon_s3(definitions) click to toggle source
# File lib/backup-agent/storages.rb, line 36
def amazon_s3(definitions)
  definitions.map do |name, options|
    register Backup::Storages::AmazonS3 => [:amazon_s3, name, options.merge(credentials: credentials[amazon_s3: name])]
  end.flatten(1)
end
each() { |storage, type, name| ... } click to toggle source
# File lib/backup-agent/storages.rb, line 17
def each
  @groups.each do |type, storages|
    storages.each { |name, storage| yield storage, type, name }
  end
end
local(definitions) click to toggle source
# File lib/backup-agent/storages.rb, line 30
def local(definitions)
  definitions.map do |name, args|
    register Backup::Storages::Local => [:local, name, *[args].flatten(1)]
  end.flatten(1)
end
register(arg) click to toggle source

register AmazonS3 => [:amazon_s3, :default, storage constructor arguments…]

# File lib/backup-agent/storages.rb, line 24
def register(arg)
  arg.map do |klass, rest|
    (@groups[rest[0]] ||= {})[rest[1]] = klass.new(*rest.drop(2))
  end
end