Sha256: cfc878677740a607089f92f9d441774ee595a87f5abcc1eb8c775cf47b53e83e
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
module Fog module Storage class AWS private def self.hash_to_acl(acl) data = "<AccessControlPolicy>\n" if acl['Owner'] && (acl['Owner']['ID'] || acl['Owner']['DisplayName']) data << " <Owner>\n" data << " <ID>#{acl['Owner']['ID']}</ID>\n" if acl['Owner']['ID'] data << " <DisplayName>#{acl['Owner']['DisplayName']}</DisplayName>\n" if acl['Owner']['DisplayName'] data << " </Owner>\n" end grants = [acl['AccessControlList']].flatten.compact data << " <AccessControlList>\n" if grants.any? grants.each do |grant| data << " <Grant>\n" grantee = grant['Grantee'] type = case when grantee.has_key?('ID') 'CanonicalUser' when grantee.has_key?('EmailAddress') 'AmazonCustomerByEmail' when grantee.has_key?('URI') 'Group' end data << " <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"#{type}\">\n" case type when 'CanonicalUser' data << " <ID>#{grantee['ID']}</ID>\n" if grantee['ID'] data << " <DisplayName>#{grantee['DisplayName']}</DisplayName>\n" if grantee['DisplayName'] when 'AmazonCustomerByEmail' data << " <EmailAddress>#{grantee['EmailAddress']}</EmailAddress>\n" if grantee['EmailAddress'] when 'Group' data << " <URI>#{grantee['URI']}</URI>\n" if grantee['URI'] end data << " </Grantee>\n" data << " <Permission>#{grant['Permission']}</Permission>\n" data << " </Grant>\n" end data << " </AccessControlList>\n" if grants.any? data << "</AccessControlPolicy>" data end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fog-1.1.1 | lib/fog/aws/requests/storage/hash_to_acl.rb |
fog-1.1.0 | lib/fog/aws/requests/storage/hash_to_acl.rb |