Class: ArchivedRemoteObject::AwsS3::RemoteObject

Inherits:
Object
  • Object
show all
Defined in:
lib/archived_remote_object/aws_s3/remote_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, remote_client: AwsS3::Client.new) ⇒ RemoteObject

Returns a new instance of RemoteObject.



8
9
10
11
12
13
14
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 8

def initialize(
  key:,
  remote_client: AwsS3::Client.new
)
  self.key = key
  self.remote_client = remote_client
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



6
7
8
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 6

def key
  @key
end

#remote_clientObject

Returns the value of attribute remote_client.



6
7
8
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 6

def remote_client
  @remote_client
end

Instance Method Details

#assign_tag(key:, value:) ⇒ Object



26
27
28
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 26

def assign_tag(key:, value:)
  remote_client.assign_tag(key: self.key, set: [key, value])
end

#attributesObject



16
17
18
19
20
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 16

def attributes
  return @attributes if @attributes

  fetch_attributes
end

#debug_stateObject



47
48
49
50
51
52
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 47

def debug_state
  {
    restore: attributes.restore,
    storage_class: attributes.storage_class
  }
end

#deleteObject



35
36
37
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 35

def delete
  remote_client.delete(key: key)
end

#exists?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 39

def exists?
  remote_client.exists?(key: key)
end

#restore(**args) ⇒ Object



22
23
24
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 22

def restore(**args)
  remote_client.restore(**args)
end

#storage_class=(storage_class) ⇒ Object



30
31
32
33
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 30

def storage_class=(storage_class)
  # accepts STANDARD, STANDARD_IA, ONEZONE_IA, GLACIER, INTELLIGENT_TIERING, DEEP_ARCHIVE
  remote_client.assign_storage_class(key: key, storage_class: storage_class)
end

#syncObject



43
44
45
# File 'lib/archived_remote_object/aws_s3/remote_object.rb', line 43

def sync
  tap { fetch_attributes }
end