Class: RAWS::S3::ACL

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

Defined Under Namespace

Classes: AllUsers, AuthenticatedUsers, Email, Grant, Grants, Group, ID, Owner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, key = nil) ⇒ ACL

Returns a new instance of ACL.



122
123
124
125
# File 'lib/raws/s3/acl.rb', line 122

def initialize(bucket_name, key=nil)
  @bucket_name, @key = bucket_name, key
  reload
end

Instance Attribute Details

#bucket_nameObject (readonly)

Returns the value of attribute bucket_name.



120
121
122
# File 'lib/raws/s3/acl.rb', line 120

def bucket_name
  @bucket_name
end

#grantsObject (readonly)

Returns the value of attribute grants.



120
121
122
# File 'lib/raws/s3/acl.rb', line 120

def grants
  @grants
end

#keyObject (readonly)

Returns the value of attribute key.



120
121
122
# File 'lib/raws/s3/acl.rb', line 120

def key
  @key
end

#ownerObject (readonly)

Returns the value of attribute owner.



120
121
122
# File 'lib/raws/s3/acl.rb', line 120

def owner
  @owner
end

Instance Method Details

#reloadObject



131
132
133
134
135
136
# File 'lib/raws/s3/acl.rb', line 131

def reload
  doc = RAWS::S3::Adapter.get_acl(@bucket_name, @key).doc
  acp = doc['AccessControlPolicy']
  @owner  = Owner.new(acp['Owner'])
  @grants = Grants.new(acp['AccessControlList']['Grant'])
end

#saveObject



127
128
129
# File 'lib/raws/s3/acl.rb', line 127

def save
  RAWS::S3::Adapter.put_acl(@bucket_name, @key, to_xml)
end

#to_xmlObject



138
139
140
141
142
143
# File 'lib/raws/s3/acl.rb', line 138

def to_xml
  '<AccessControlPolicy>' <<
    owner.to_xml  <<
    grants.to_xml <<
  '</AccessControlPolicy>'
end