Module: S3::BucketsExtension

Defined in:
lib/s3/buckets_extension.rb

Instance Method Summary collapse

Instance Method Details

#build(name) ⇒ Object

Builds new bucket with given name



4
5
6
# File 'lib/s3/buckets_extension.rb', line 4

def build(name)
  Bucket.send(:new, proxy_owner, name)
end

#destroy_all(force = false) ⇒ Object

Destroys all buckets in the service. Doesn’t destroy non-empty buckets by default, pass true to force destroy (USE WITH CARE!).



25
26
27
# File 'lib/s3/buckets_extension.rb', line 25

def destroy_all(force = false)
  proxy_target.each { |bucket| bucket.destroy(force) }
end

#find_allObject

Finds all buckets in the service



19
20
21
# File 'lib/s3/buckets_extension.rb', line 19

def find_all
  proxy_target
end

#find_first(name) ⇒ Object Also known as: find

Finds the bucket with given name (only those which exist and You have access to it) return nil in case Error::NoSuchBucket or Error::ForbiddenBucket



10
11
12
13
14
15
# File 'lib/s3/buckets_extension.rb', line 10

def find_first(name)
  bucket = build(name)
  bucket.retrieve
rescue Error::ForbiddenBucket, Error::NoSuchBucket
  nil
end