Class: Heirloom::ACL::S3
- Inherits:
-
Object
- Object
- Heirloom::ACL::S3
- Includes:
- Utils::Email
- Defined in:
- lib/heirloom/acl/s3.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
Returns the value of attribute accounts.
-
#config ⇒ Object
Returns the value of attribute config.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#region ⇒ Object
Returns the value of attribute region.
Instance Method Summary collapse
- #allow_read_access_from_accounts(args) ⇒ Object
-
#initialize(args) ⇒ S3
constructor
A new instance of S3.
Methods included from Utils::Email
Constructor Details
#initialize(args) ⇒ S3
Returns a new instance of S3.
8 9 10 11 12 |
# File 'lib/heirloom/acl/s3.rb', line 8 def initialize(args) self.config = args[:config] self.region = args[:region] self.logger = config.logger end |
Instance Attribute Details
#accounts ⇒ Object
Returns the value of attribute accounts.
6 7 8 |
# File 'lib/heirloom/acl/s3.rb', line 6 def accounts @accounts end |
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/heirloom/acl/s3.rb', line 6 def config @config end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/heirloom/acl/s3.rb', line 6 def logger @logger end |
#region ⇒ Object
Returns the value of attribute region.
6 7 8 |
# File 'lib/heirloom/acl/s3.rb', line 6 def region @region end |
Instance Method Details
#allow_read_access_from_accounts(args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/heirloom/acl/s3.rb', line 14 def allow_read_access_from_accounts(args) bucket = args[:bucket] key_name = args[:key_name] key_folder = args[:key_folder] accounts = args[:accounts] key = "#{key_folder}/#{key_name}" current_acls = s3.get_object_acl :bucket => bucket, :object_name => key name = current_acls['Owner']['Name'] id = current_acls['Owner']['ID'] grants = build_bucket_grants :id => id, :name => name, :accounts => accounts accounts.each do |a| logger.debug "Authorizing #{a} to s3://#{bucket}/#{key}." end s3.put_object_acl bucket, key, grants end |