Class: Backup::Credentials
- Inherits:
-
Object
- Object
- Backup::Credentials
- Includes:
- Singleton
- Defined in:
- lib/backup-agent/credentials.rb
Instance Method Summary collapse
-
#[](pair) ⇒ Object
Usage: credentials(type: :name).
- #amazon_s3(definitions) ⇒ Object
-
#define(definitions) ⇒ Object
define Class => [:type, :name, arguments…].
-
#initialize ⇒ Credentials
constructor
A new instance of Credentials.
- #mysql(definitions) ⇒ Object
Constructor Details
#initialize ⇒ Credentials
Returns a new instance of Credentials.
8 9 10 |
# File 'lib/backup-agent/credentials.rb', line 8 def initialize @groups = {} end |
Instance Method Details
#[](pair) ⇒ Object
Usage: credentials(type: :name)
13 14 15 |
# File 'lib/backup-agent/credentials.rb', line 13 def [](pair) @groups.fetch(pair.keys[0]).fetch(pair.values[0]) end |
#amazon_s3(definitions) ⇒ Object
30 31 32 33 34 |
# File 'lib/backup-agent/credentials.rb', line 30 def amazon_s3(definitions) definitions.map do |name, args| define Backup::Storages::AmazonS3::Credentials => [:amazon_s3, name, *[args].flatten(1)] end.flatten(1) end |
#define(definitions) ⇒ Object
define Class => [:type, :name, arguments…]
18 19 20 21 22 |
# File 'lib/backup-agent/credentials.rb', line 18 def define(definitions) definitions.map do |klass, definition| (@groups[definition[0]] ||= {})[definition[1]] = klass.new(*definition.drop(2)) end end |
#mysql(definitions) ⇒ Object
24 25 26 27 28 |
# File 'lib/backup-agent/credentials.rb', line 24 def mysql(definitions) definitions.map do |name, args| define Backup::Tasks::MySQL::Credentials => [:mysql, name, *[args].flatten(1)] end.flatten(1) end |