Class: Canistor::Storage::Part

Inherits:
Object
  • Object
show all
Defined in:
lib/canistor/storage/part.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Part

Returns a new instance of Part.



14
15
16
17
18
# File 'lib/canistor/storage/part.rb', line 14

def initialize(**attributes)
  attributes.each do |name, value|
    send("#{name}=", value)
  end
end

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



7
8
9
# File 'lib/canistor/storage/part.rb', line 7

def bucket
  @bucket
end

#dataObject

Returns the value of attribute data.



12
13
14
# File 'lib/canistor/storage/part.rb', line 12

def data
  @data
end

#keyObject

Returns the value of attribute key.



8
9
10
# File 'lib/canistor/storage/part.rb', line 8

def key
  @key
end

#numberObject

Returns the value of attribute number.



10
11
12
# File 'lib/canistor/storage/part.rb', line 10

def number
  @number
end

#regionObject

Returns the value of attribute region.



6
7
8
# File 'lib/canistor/storage/part.rb', line 6

def region
  @region
end

#upload_idObject

Returns the value of attribute upload_id.



9
10
11
# File 'lib/canistor/storage/part.rb', line 9

def upload_id
  @upload_id
end

Instance Method Details

#attributesObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/canistor/storage/part.rb', line 33

def attributes
  {
    region: region,
    bucket: bucket,
    key: key,
    upload_id: upload_id,
    number: number,
    digest: digest,
    etag: etag
  }
end

#etagObject



25
26
27
# File 'lib/canistor/storage/part.rb', line 25

def etag
  '"' + digest + '"'
end

#put(context, subject) ⇒ Object



20
21
22
23
# File 'lib/canistor/storage/part.rb', line 20

def put(context, subject)
  write(context.http_request.body.read)
  context.http_response.signal_headers(200, identity_headers)
end

#sizeObject



29
30
31
# File 'lib/canistor/storage/part.rb', line 29

def size
  data&.size
end