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, #initialize, #inspect, #merge_attributes

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#bucketsObject



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

def buckets
  @buckets
end

#destroyObject



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

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

#locationObject



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

def location
  data = connection.get_bucket_location(@name)
  data.body['LocationConstraint']
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

#reloadObject



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

def reload
  new_attributes = buckets.get(@name).attributes
  merge_attributes(new_attributes)
end

#saveObject



52
53
54
55
56
57
58
59
# File 'lib/fog/aws/models/s3/bucket.rb', line 52

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