Sha256: e595b7dca2cf2cf41ee1caf559fc57c2c32c23cb44a5eb4468e98b897f3259c5

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

module AWS
  module S3
    # Entities in S3 have an associated owner (the person who created them). The owner is a canonical representation of an 
    # entity in the S3 system. It has an <tt>id</tt> and a <tt>display_name</tt>. 
    # 
    # These attributes can be used when specifying a ACL::Grantee for an ACL::Grant.
    #
    # You can retrieve the owner of the current account by calling Owner.current.
    class Owner
      undef_method :id if method_defined?(:id) # Get rid of Object#id
      include SelectiveAttributeProxy
      
      class << self
        # The owner of the current account.
        def current
          response = Service.get('/')
          # new(response.parsed['owner']) if response.parsed['owner']
          #TODO: This is a pretty hackish way to get the current account owner.
          response.parsed['contents'][0]['owner'] if (response.parsed['contents'] && response.parsed['contents'][0])
        end
        memoized :current
      end
      
      def initialize(attributes = {}) #:nodoc:
        @attributes = attributes
      end
      
      def ==(other_owner) #:nodoc:
        hash == other_owner.hash
      end
      
      def hash #:nodoc
        [id, display_name].join.hash
      end
      
      private
        def proxiable_attribute?(name)
          valid_attributes.include?(name)
        end
        
        def valid_attributes
          %w(id display_name)
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
fmalamitsas-aws-s3-0.6.2.1254423625 lib/aws/s3/owner.rb
sauberia-aws-s3-0.6.2.1254423624 lib/aws/s3/owner.rb