Method: S33r::Bucket#initialize

Defined in:
lib/s33r/bucket.rb

#initialize(bucket_name, options = {}) {|_self| ... } ⇒ Bucket

options:

  • :check => true: if setting a :bucket option, the default behaviour is not to check whether the bucket actually exists on S3. If you pass this option, S33r will only set the bucket if it is on S3 and accessible; if it isn’t, an error is raised (NoSuchBucket).

  • :create => true: if the bucket doesn’t exist, try to create it. S33r will check before trying to create the bucket and will just return the bucket if it does.

Yields:

  • (_self)

Yield Parameters:

  • _self (S33r::Bucket)

    the object that the method was called on



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/s33r/bucket.rb', line 15

def initialize(bucket_name, options={})
  bucket_name_valid?(bucket_name)
  
  super(options)

  if options[:create]
    options[:bucket] = bucket_name
    raise last_response.s3_error unless do_put(nil, options).ok?
  end
  if options[:check]
    raise InvalidBucket, "Bucket #{name} does not exist" unless bucket_exists?(bucket_name)
  end
  @name = bucket_name
  
  yield self if block_given?
end