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

Constructor Details

#initialize(attributes = {}) ⇒ Bucket

Returns a new instance of Bucket.



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

def initialize(attributes = {})
  super
end

Instance Method Details

#bucketsObject



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

def buckets
  @buckets
end

#destroyObject



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

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

#locationObject



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

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

#objectsObject



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

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

#payerObject



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

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

#payer=(new_payer) ⇒ Object



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

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

#reloadObject



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

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

#saveObject



57
58
59
60
61
62
63
64
65
# File 'lib/fog/aws/models/s3/bucket.rb', line 57

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