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



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

def buckets
  @buckets
end

#destroyObject



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

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

#locationObject



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

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

#objectsObject



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

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

#payerObject



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

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

#payer=(new_payer) ⇒ Object



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

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

#reloadObject



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

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

#saveObject



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

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