Class: RAWS::S3::ACL::Grants

Inherits:
Array
  • Object
show all
Defined in:
lib/raws/s3/acl.rb

Instance Method Summary collapse

Constructor Details

#initialize(grants) ⇒ Grants

Returns a new instance of Grants.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/raws/s3/acl.rb', line 92

def initialize(grants)
  super()
  grants.each do |grant|
    grantee, permission = grant['Grantee'], grant['Permission']
    if id = grantee['ID']
      push ID.new(id, permission, grantee['DisplayName'])
    elsif email = grantee['EmailAddress']
      push Email.new(email, permission)
    else
      case grantee['URI']
      when 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'
        push AuthenticatedUsers.new(permission)
      when 'http://acs.amazonaws.com/groups/global/AllUsers'
        push AllUsers.new(permission)
      end
    end
  end
end

Instance Method Details

#to_xmlObject



111
112
113
114
115
116
117
# File 'lib/raws/s3/acl.rb', line 111

def to_xml
  '<AccessControlList>' <<
    map do |grant|
      grant.to_xml
    end.join <<
  '</AccessControlList>'
end