Sha256: f1e1c76ac4ec1aeb66bc88897b094c6f8bd1114e07aad287fa39ab186f43a5c8

Contents?: true

Size: 1.43 KB

Versions: 18

Compression:

Stored size: 1.43 KB

Contents

module Fog
  module AWS
    class S3

      class Bucket < Fog::Model

        attribute :creation_date, 'CreationDate'
        attribute :location
        attribute :name,          'Name'
        attribute :owner

        def buckets
          @buckets
        end

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

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

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

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

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

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

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

        private

        def buckets=(new_buckets)
          @buckets = new_buckets
        end

      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fog-0.0.22 lib/fog/aws/models/s3/bucket.rb
fog-0.0.21 lib/fog/aws/models/s3/bucket.rb
fog-0.0.20 lib/fog/aws/models/s3/bucket.rb
fog-0.0.19 lib/fog/aws/models/s3/bucket.rb
fog-0.0.18 lib/fog/aws/models/s3/bucket.rb
fog-0.0.17 lib/fog/aws/models/s3/bucket.rb
fog-0.0.16 lib/fog/aws/models/s3/bucket.rb
fog-0.0.15 lib/fog/aws/models/s3/bucket.rb
fog-0.0.14 lib/fog/aws/models/s3/bucket.rb
fog-0.0.13 lib/fog/aws/models/s3/bucket.rb
fog-0.0.12 lib/fog/aws/models/s3/bucket.rb
fog-0.0.11 lib/fog/aws/models/s3/bucket.rb
fog-0.0.10 lib/fog/aws/models/s3/bucket.rb
fog-0.0.9 lib/fog/aws/models/s3/bucket.rb
fog-0.0.8 lib/fog/aws/models/s3/bucket.rb
fog-0.0.7 lib/fog/aws/models/s3/bucket.rb
fog-0.0.6 lib/fog/aws/models/s3/bucket.rb
fog-0.0.5 lib/fog/aws/models/s3/bucket.rb