class ArchivedRemoteObject::Archive::RestoredObject

Attributes

archived_object[RW]

Public Class Methods

new( key:, archived_object: Archive::ArchivedObject.new(key: key) ) click to toggle source
# File lib/archived_remote_object/archive/restored_object.rb, line 7
def initialize(
  key:,
  archived_object: Archive::ArchivedObject.new(key: key)
)
  self.archived_object = archived_object
end

Public Instance Methods

call() click to toggle source
# File lib/archived_remote_object/archive/restored_object.rb, line 14
def call
  assign_attributes

  if attributes.status == :archived
    archived_object.restore
    attributes.status = :restoration_initiated
  end

  attributes
end

Private Instance Methods

assign_attributes() click to toggle source
# File lib/archived_remote_object/archive/restored_object.rb, line 31
def assign_attributes # rubocop:disable Metrics/AbcSize
  if archived_object.available?
    attributes.status = :available
  elsif archived_object.restore_in_progress?
    attributes.status = :in_progress
    attributes.debug_state = archived_object.debug_state
  else
    attributes.status = :archived
    attributes.debug_state = archived_object.debug_state
  end
end
attributes() click to toggle source
# File lib/archived_remote_object/archive/restored_object.rb, line 27
def attributes
  @attributes ||= OpenStruct.new
end