lib/backup/record/s3.rb in backup-2.1.0 vs lib/backup/record/s3.rb in backup-2.1.1
- old
+ new
@@ -1,34 +1,33 @@
module Backup
module Record
class S3 < ActiveRecord::Base
-
- # Establishes a connection with the SQLite3
- # local database to avoid conflict with users
- # Production database.
- # establish_connection(
- # :adapter => "sqlite3",
- # :database => "db/backup.sqlite3",
- # :pool => 5,
- # :timeout => 5000 )
- set_table_name 'backup_s3'
+ if connection.table_exists?('backup')
+ set_table_name 'backup'
+ default_scope \
+ :order => 'created_at desc',
+ :conditions => {:storage => 's3'}
+ else
+ set_table_name 'backup_s3'
+ attr_accessor :storage
+ default_scope \
+ :order => 'created_at desc'
+ end
- # Scopes
- default_scope :order => 'created_at desc'
-
# Callbacks
after_save :clean_backups
# Attributes
attr_accessor :adapter_config, :keep_backups
# Receives the options hash and stores it
# Sets the S3 values
def load_adapter(adapter)
self.adapter_config = adapter
+ self.storage = 's3'
self.trigger = adapter.procedure.trigger
- self.adapter = adapter.procedure.adapter_name
+ self.adapter = adapter.procedure.adapter_name.to_s
self.filename = adapter.final_file
self.bucket = adapter.procedure.get_storage_configuration.attributes['bucket']
self.keep_backups = adapter.procedure.attributes['keep_backups']
end
\ No newline at end of file