Class: Backup::Configuration::Base

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Defined in:
lib/backup/configuration/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

generate_attributes

Constructor Details

#initialize(trigger) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/backup/configuration/base.rb', line 9

def initialize(trigger)
  @trigger = trigger
  @adapter_configuration = Backup::Configuration::Adapter.new
  @storage_configuration = Backup::Configuration::Storage.new
end

Instance Attribute Details

#adapter_nameObject

Returns the value of attribute adapter_name.



7
8
9
# File 'lib/backup/configuration/base.rb', line 7

def adapter_name
  @adapter_name
end

#storage_nameObject

Returns the value of attribute storage_name.



7
8
9
# File 'lib/backup/configuration/base.rb', line 7

def storage_name
  @storage_name
end

#triggerObject

Returns the value of attribute trigger.



7
8
9
# File 'lib/backup/configuration/base.rb', line 7

def trigger
  @trigger
end

Instance Method Details

#adapter(adapter, &block) ⇒ Object



15
16
17
18
# File 'lib/backup/configuration/base.rb', line 15

def adapter(adapter, &block)
  @adapter_name = adapter
  @adapter_configuration.instance_eval &block
end

#get_adapter_configurationObject



46
47
48
# File 'lib/backup/configuration/base.rb', line 46

def get_adapter_configuration
  @adapter_configuration
end

#get_storage_configurationObject



50
51
52
# File 'lib/backup/configuration/base.rb', line 50

def get_storage_configuration
  @storage_configuration
end

#initialize_recordObject



36
37
38
39
40
41
42
43
44
# File 'lib/backup/configuration/base.rb', line 36

def initialize_record
  case @storage_name.to_sym
    when :s3    then Backup::Record::S3.new
    when :scp   then Backup::Record::SCP.new
    when :ftp   then Backup::Record::FTP.new
    when :sftp  then Backup::Record::SFTP.new
    when :local then Backup::Record::Local.new
  end        
end

#initialize_storage(adapter) ⇒ Object

Initializes the storing process depending on the store settings



26
27
28
29
30
31
32
33
34
# File 'lib/backup/configuration/base.rb', line 26

def initialize_storage(adapter)
  case @storage_name.to_sym
    when :s3    then Backup::Storage::S3.new(adapter)
    when :scp   then Backup::Storage::SCP.new(adapter)
    when :ftp   then Backup::Storage::FTP.new(adapter)
    when :sftp  then Backup::Storage::SFTP.new(adapter)
    when :local then Backup::Storage::Local.new(adapter)
  end
end

#storage(storage, &block) ⇒ Object



20
21
22
23
# File 'lib/backup/configuration/base.rb', line 20

def storage(storage, &block)
  @storage_name = storage
  @storage_configuration.instance_eval &block
end