Class: Backup::Storages
- Inherits:
-
Object
- Object
- Backup::Storages
- Includes:
- Enumerable, Singleton
- Defined in:
- lib/backup-agent/storages/base.rb,
lib/backup-agent/storages.rb,
lib/backup-agent/storages/local.rb,
lib/backup-agent/storages/amazon-s3.rb
Overview
Storage based on Amazon S3
Defined Under Namespace
Classes: AmazonS3, Base, Local
Instance Method Summary collapse
- #[](pair) ⇒ Object
- #amazon_s3(definitions) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Storages
constructor
A new instance of Storages.
- #local(definitions) ⇒ Object
-
#register(arg) ⇒ Object
register AmazonS3 => [:amazon_s3, :default, storage constructor arguments…].
Constructor Details
#initialize ⇒ Storages
Returns a new instance of Storages.
9 10 11 |
# File 'lib/backup-agent/storages.rb', line 9 def initialize @groups = {} end |
Instance Method Details
#[](pair) ⇒ Object
13 14 15 |
# File 'lib/backup-agent/storages.rb', line 13 def [](pair) @groups.fetch(pair.keys[0]).fetch(pair.values[0]) end |
#amazon_s3(definitions) ⇒ Object
36 37 38 39 40 |
# File 'lib/backup-agent/storages.rb', line 36 def amazon_s3(definitions) definitions.map do |name, | register Backup::Storages::AmazonS3 => [:amazon_s3, name, .merge(credentials: credentials[amazon_s3: name])] end.flatten(1) end |
#each ⇒ Object
17 18 19 20 21 |
# 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) ⇒ Object
30 31 32 33 34 |
# 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) ⇒ Object
register AmazonS3 => [:amazon_s3, :default, storage constructor arguments…]
24 25 26 27 28 |
# 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 |