Class: AWS::S3::ACL::Policy

Inherits:
Object
  • Object
show all
Includes:
SelectiveAttributeProxy
Defined in:
lib/aws/s3/acl.rb,
lib/aws/s3/response.rb

Overview

The ACL::Policy class lets you inspect and modify access controls for buckets and objects. A policy is made up of one or more Grants which specify a permission and a Grantee to whom that permission is granted.

Buckets and objects are given a default access policy which contains one grant permitting the owner of the bucket or object FULL_CONTROL over its contents. This means they can read the object, write to the object, as well as read and write its policy.

The acl method for both buckets and objects returns the policy object for that entity:

policy = Bucket.acl('some-bucket')

The grants method of a policy exposes its grants. You can treat this collection as an array and push new grants onto it:

policy.grants << grant

Check the documentation for Grant and Grantee for more details on how to create new grants.

Defined Under Namespace

Modules: GrantListExtensions Classes: Builder, Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Policy

Returns a new instance of Policy.



123
124
125
126
127
128
# File 'lib/aws/s3/acl.rb', line 123

def initialize(attributes = {})
  @attributes = attributes
  @grants     = [].extend(GrantListExtensions)
  extract_owner!  if owner?
  extract_grants! if grants?
end

Instance Attribute Details

#grantsObject

Returns the value of attribute grants.



121
122
123
# File 'lib/aws/s3/acl.rb', line 121

def grants
  @grants
end

#ownerObject

Returns the value of attribute owner.



121
122
123
# File 'lib/aws/s3/acl.rb', line 121

def owner
  @owner
end

Instance Method Details

#to_xmlObject

The xml representation of the policy.



131
132
133
# File 'lib/aws/s3/acl.rb', line 131

def to_xml
  Builder.new(owner, grants).to_s
end