Method: S33r::S3ACL::Grantee.from_xml

Defined in:
lib/s33r/s3_acl.rb

.from_xml(grantee_xml) ⇒ Object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/s33r/s3_acl.rb', line 227

def self.from_xml(grantee_xml)
  grantee_type = grantee_xml['type']

  case grantee_type
    when GRANTEE_TYPES[:amazon_customer]
      AmazonCustomer.new(grantee_xml.xget('EmailAddress'))
    when GRANTEE_TYPES[:canonical_user]
      CanonicalUser.from_xml(grantee_xml)
    when GRANTEE_TYPES[:group]
      uri = grantee_xml.xget('URI')
      # last part of the path is the group type
      path = uri.gsub(/#{GROUP_ACL_URI_BASE}/, '')

      group_type = :all_users
      S3_GROUP_TYPES.each { |k,v| group_type = k if v == path }
      Group.new(group_type)
  end
end