Class: Fog::AWS::S3::Bucket

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/s3/bucket.rb

Instance Method Summary collapse

Methods inherited from Model

aliases, attribute, #attributes, attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes, #reload

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



12
13
14
15
16
17
# File 'lib/fog/aws/models/s3/bucket.rb', line 12

def destroy
  connection.delete_bucket(@name)
  true
rescue Fog::Errors::NotFound
  false
end

#locationObject



19
20
21
22
# File 'lib/fog/aws/models/s3/bucket.rb', line 19

def location
  data = connection.get_bucket_location(@name)
  data.body['LocationConstraint']
end

#location=(new_location) ⇒ Object



24
25
26
# File 'lib/fog/aws/models/s3/bucket.rb', line 24

def location=(new_location)
  @location = new_location
end

#objectsObject



28
29
30
31
32
33
34
35
# File 'lib/fog/aws/models/s3/bucket.rb', line 28

def objects
  @objects ||= begin
    Fog::AWS::S3::Objects.new(
      :bucket       => self,
      :connection   => connection
    )
  end
end

#payerObject



37
38
39
40
# File 'lib/fog/aws/models/s3/bucket.rb', line 37

def payer
  data = connection.get_request_payment(@name)
  data.body['Payer']
end

#payer=(new_payer) ⇒ Object



42
43
44
45
# File 'lib/fog/aws/models/s3/bucket.rb', line 42

def payer=(new_payer)
  connection.put_request_payment(@name, new_payer)
  @payer = new_payer
end

#saveObject



47
48
49
50
51
52
53
54
# File 'lib/fog/aws/models/s3/bucket.rb', line 47

def save
  options = {}
  if @location
    options['LocationConstraint'] = @location
  end
  connection.put_bucket(@name, options)
  true
end