Module: RAWS::S3::Model::InstanceMethods

Defined in:
lib/raws/s3/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



55
56
57
# File 'lib/raws/s3/model.rb', line 55

def key
  @key
end

Instance Method Details

#aclObject



70
71
72
# File 'lib/raws/s3/model.rb', line 70

def acl
  self.class.acl @key
end

#after_delete(response) ⇒ Object



111
# File 'lib/raws/s3/model.rb', line 111

def after_delete(response); end

#after_initializeObject



109
# File 'lib/raws/s3/model.rb', line 109

def after_initialize; end

#after_receive(response) ⇒ Object



113
# File 'lib/raws/s3/model.rb', line 113

def after_receive(response); end

#after_send(response) ⇒ Object



115
# File 'lib/raws/s3/model.rb', line 115

def after_send(response); end

#before_deleteObject



110
# File 'lib/raws/s3/model.rb', line 110

def before_delete; end

#before_receiveObject



112
# File 'lib/raws/s3/model.rb', line 112

def before_receive; end

#before_sendObject



114
# File 'lib/raws/s3/model.rb', line 114

def before_send; end

#deleteObject



74
75
76
77
78
# File 'lib/raws/s3/model.rb', line 74

def delete
  before_delete
  response = self.class.delete_object @key
  after_delete response
end

#headerObject



62
63
64
# File 'lib/raws/s3/model.rb', line 62

def header
  @header ||= self.class.head(@key)
end

#initialize(key, header = nil) ⇒ Object



57
58
59
60
# File 'lib/raws/s3/model.rb', line 57

def initialize(key, header=nil)
  @key, @header, @metadata = key, header, nil
  after_initialize
end

#metadataObject



66
67
68
# File 'lib/raws/s3/model.rb', line 66

def 
  @metadata ||= RAWS::S3::Metadata.new header
end

#receive(header = {}, &block) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/raws/s3/model.rb', line 96

def receive(header={}, &block)
  before_receive
  ret = self.class.get_object(@key, header) do |request|
    response = request.send
    @header  = response.header
    .decode @header
    response.receive &block
    response
  end
  after_send ret
  ret
end

#send(header = {}, &block) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/raws/s3/model.rb', line 80

def send(header={}, &block)
  before_send
  if @header
    @header.merge! header
  else
    @header = header
  end
  response = self.class.put_object(
    @key,
    @header.merge(.encode)
  ) do |request|
    request.send &block
  end
  after_send response
end