Class: ArchivedRemoteObject::Archive::ArchivedObject
- Inherits:
-
Object
- Object
- ArchivedRemoteObject::Archive::ArchivedObject
- Defined in:
- lib/archived_remote_object/archive/archived_object.rb
Constant Summary collapse
- CantBeRestoredError =
Class.new(StandardError)
- CantStopArchivingOnDurationError =
Class.new(StandardError)
Instance Method Summary collapse
- #archived? ⇒ Boolean
- #available? ⇒ Boolean
- #debug_state ⇒ Object
-
#initialize(key:, remote_object: AwsS3::ArchivedObject.new(key: key)) ⇒ ArchivedObject
constructor
A new instance of ArchivedObject.
- #restore ⇒ Object
- #restore_in_progress? ⇒ Boolean
- #restored? ⇒ Boolean
- #stop_archiving_on_duration ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize(key:, remote_object: AwsS3::ArchivedObject.new(key: key)) ⇒ ArchivedObject
Returns a new instance of ArchivedObject.
9 10 11 12 13 14 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 9 def initialize( key:, remote_object: AwsS3::ArchivedObject.new(key: key) ) self.remote_object = remote_object end |
Instance Method Details
#archived? ⇒ Boolean
16 17 18 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 16 def archived? remote_object.archived? end |
#available? ⇒ Boolean
44 45 46 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 44 def available? !archived? || restored? end |
#debug_state ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 52 def debug_state { restore_in_progress: restore_in_progress?, restored: restored?, **remote_object.debug_state } end |
#restore ⇒ Object
32 33 34 35 36 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 32 def restore raise CantBeRestoredError if available? || restore_in_progress? remote_object.restore end |
#restore_in_progress? ⇒ Boolean
20 21 22 23 24 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 20 def restore_in_progress? return false unless archived? remote_object.restore_in_progress? end |
#restored? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 26 def restored? return false unless archived? remote_object.restored? end |
#stop_archiving_on_duration ⇒ Object
38 39 40 41 42 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 38 def stop_archiving_on_duration raise CantStopArchivingOnDurationError if !restored? || restore_in_progress? remote_object.stop_archiving_on_duration end |
#sync ⇒ Object
48 49 50 |
# File 'lib/archived_remote_object/archive/archived_object.rb', line 48 def sync tap { remote_object.sync } end |