Sha256: 56f99752c3c2237159e45cbf4073ef3d42d611ebcb9478d13211da607352bedf

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module AWS
  module S3
    # The service lets you find out general information about your account, like what buckets you have. 
    # 
    #   Service.buckets
    #   # => []
    class Service < Base
      @@response = nil #:nodoc:
      
      class << self
        # List all your buckets
        def buckets
          response = get('/')
          if response.empty?
            []
          else
            response.buckets.map {|attributes| Bucket.new(attributes)}
          end
        end
        memoized :buckets
        
        # Sometimes methods that make requests to the S3 servers return some object, like a Bucket or an S3Object. 
        # Othertimes they return just <tt>true</tt>. Other times they raise an exception that you may want to rescue. Despite all these 
        # possible outcomes, every method that makes a request stores its response object for you in Service.response. You can always 
        # get to the last request's response via Service.response.
        # 
        #   objects = Bucket.objects('jukebox')
        #   Service.response.success?
        #   # => true
        #
        # This is also useful when an error exception is raised in the console which you weren't expecting. You can 
        # root around in the response to get more details of what might have gone wrong.
        def response
          @@response
        end
        
        def response=(response) #:nodoc:
          @@response = response
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aws-s3-0.2.0 lib/aws/s3/service.rb
aws-s3-0.1.0 lib/aws/s3/service.rb
aws-s3-0.1.2 lib/aws/s3/service.rb
aws-s3-0.1.1 lib/aws/s3/service.rb