Class: ServerBackups::OrderedBackupFileCollection
- Inherits:
-
Object
- Object
- ServerBackups::OrderedBackupFileCollection
- Defined in:
- lib/server_backups/ordered_backup_file_collection.rb
Constant Summary collapse
- INCREMENTAL =
/incremental/i
Instance Attribute Summary collapse
-
#s3_collection ⇒ Object
readonly
Returns the value of attribute s3_collection.
Instance Method Summary collapse
- #full_backup_for(restore_point) ⇒ Object
- #full_backups ⇒ Object
- #incremental_backups ⇒ Object
- #incremental_backups_for(restore_point) ⇒ Object
-
#initialize(s3_collection) ⇒ OrderedBackupFileCollection
constructor
A new instance of OrderedBackupFileCollection.
Constructor Details
#initialize(s3_collection) ⇒ OrderedBackupFileCollection
Returns a new instance of OrderedBackupFileCollection.
6 7 8 |
# File 'lib/server_backups/ordered_backup_file_collection.rb', line 6 def initialize(s3_collection) @s3_collection = s3_collection end |
Instance Attribute Details
#s3_collection ⇒ Object (readonly)
Returns the value of attribute s3_collection.
5 6 7 |
# File 'lib/server_backups/ordered_backup_file_collection.rb', line 5 def s3_collection @s3_collection end |
Instance Method Details
#full_backup_for(restore_point) ⇒ Object
10 11 12 13 14 |
# File 'lib/server_backups/ordered_backup_file_collection.rb', line 10 def full_backup_for(restore_point) sorted(full_backups).reverse.find do |file| (file) <= restore_point end end |
#full_backups ⇒ Object
21 22 23 |
# File 'lib/server_backups/ordered_backup_file_collection.rb', line 21 def full_backups s3_collection.reject { |file| INCREMENTAL =~ file.key } end |
#incremental_backups ⇒ Object
25 26 27 28 |
# File 'lib/server_backups/ordered_backup_file_collection.rb', line 25 def incremental_backups @incremental_backups ||= sorted(s3_collection.select { |file| INCREMENTAL =~ file.key }).to_a end |
#incremental_backups_for(restore_point) ⇒ Object
16 17 18 |
# File 'lib/server_backups/ordered_backup_file_collection.rb', line 16 def incremental_backups_for(restore_point) sorted eligible_incremental_backups(restore_point) end |