lib/heirloom/acl/s3.rb in heirloom-0.10.1 vs lib/heirloom/acl/s3.rb in heirloom-0.11.0.beta.1
- old
+ new
@@ -1,8 +1,9 @@
module Heirloom
module ACL
class S3
+ include Heirloom::Utils::Email
attr_accessor :accounts, :config, :logger, :region
def initialize(args)
self.config = args[:config]
@@ -39,19 +40,14 @@
name = args[:name]
accounts = args[:accounts]
a = Array.new
- # Add each account email as read access
accounts.each do |g|
- a << {
- 'Grantee' => { 'EmailAddress' => g } ,
- 'Permission' => 'READ'
- }
+ a << { 'Grantee' => grantee(g), 'Permission' => 'READ' }
end
- # Grand owner full access
a << { 'Grantee' => { 'DisplayName' => name, 'ID' => id },
'Permission' => 'FULL_CONTROL'
}
{
@@ -64,9 +60,13 @@
end
def s3
@s3 ||= AWS::S3.new :config => @config,
:region => @region
+ end
+
+ def grantee(account)
+ valid_email?(account) ? { 'EmailAddress' => account } : { 'ID' => account }
end
end
end
end