Class: S33r::S3ACL::CanonicalUser

Inherits:
Grantee
  • Object
show all
Defined in:
lib/s33r/s3_acl.rb

Overview

An S3 user.

Instance Attribute Summary collapse

Attributes inherited from Grantee

#grantee_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Grantee

#==, #method_missing

Constructor Details

#initialize(user_id, display_name) ⇒ CanonicalUser

owner_xml_doc: XML::Document or Node instance, representing an <Owner> node from inside a ListBucketResult <Contents> element (see docs.amazonwebservices.com/AmazonS3/2006-03-01/) or an ACL <Grantee> element.



270
271
272
273
274
# File 'lib/s33r/s3_acl.rb', line 270

def initialize(user_id, display_name)
  @grantee_type = GRANTEE_TYPES[:canonical_user]
  @user_id = user_id
  @display_name = display_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class S33r::S3ACL::Grantee

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



264
265
266
# File 'lib/s33r/s3_acl.rb', line 264

def display_name
  @display_name
end

#user_idObject

Returns the value of attribute user_id.



264
265
266
# File 'lib/s33r/s3_acl.rb', line 264

def user_id
  @user_id
end

Class Method Details

.from_xml(user_xml_doc) ⇒ Object

Create a user object from an XML fragment with ID and DisplayName elements. (Both ACL documents and bucket listings represent users this way.)



279
280
281
282
283
# File 'lib/s33r/s3_acl.rb', line 279

def self.from_xml(user_xml_doc)
  user_id = user_xml_doc.xget('ID')
  display_name = user_xml_doc.xget('DisplayName')
  new(user_id, display_name)
end

Instance Method Details

#to_sObject



285
286
287
# File 'lib/s33r/s3_acl.rb', line 285

def to_s
  "Canonical user '#{@display_name}' (with user ID '#{@user_id}')"
end