Class: Canistor::Storage::Object::CopyObjectResult

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

Overview

Renders the result of a copy request.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_object, object) ⇒ CopyObjectResult

Returns a new instance of CopyObjectResult.



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

def initialize(source_object, object)
  @source_object, @object = source_object, object
end

Class Method Details

.serve(context, subject, source_object, object) ⇒ Object



29
30
31
32
33
# File 'lib/canistor/storage/object.rb', line 29

def self.serve(context, subject, source_object, object)
  result = new(source_object, object)
  context.http_response.signal_headers(200, result.headers)
  context.http_response.signal_data(result.to_xml)
end

Instance Method Details

#headersObject



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

def headers
  @object.identity_headers.merge(
    'x-amz-copy-source-version-id' => @source_object.version_id
  )
end

#to_xmlObject



20
21
22
23
24
25
26
27
# File 'lib/canistor/storage/object.rb', line 20

def to_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.CopyObjectResult do
      xml.LastModified @object.last_modified
      xml.ETag @object.etag
    end
  end.to_xml
end