1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Add an acl property that will allow setting of acls strings. Also, add fix the public property to now toggle the appropriate acl string.

This commit is contained in:
Rupak Ganguly 2011-07-13 19:27:58 -04:00
parent a60b4bdfb8
commit 8fd2700a2a

View file

@ -12,6 +12,14 @@ module Fog
attribute :bytes, :aliases => 'X-Container-Bytes-Used'
attribute :count, :aliases => 'X-Container-Object-Count'
def acl=(new_acl)
valid_acls = ['private', 'public-read', 'public-write', 'public-read-write']
unless valid_acls.include?(new_acl)
raise ArgumentError.new("acl must be one of [#{valid_acls.join(', ')}]")
end
@acl = new_acl
end
def destroy
requires :key
connection.delete_container(key)
@ -34,6 +42,11 @@ module Fog
end
def public=(new_public)
if new_public
@acl = 'public-read'
else
@acl = 'private'
end
@public = new_public
end
@ -64,7 +77,11 @@ module Fog
def save
requires :key
connection.put_container(key)
options = {}
if @acl
options.merge!(connection.acl_to_header(@acl))
end
connection.put_container(key, options)
# Added an extra check to see if CDN is nil i.e. when CDN provider is not implemented yet.
if !connection.cdn.nil?
if @public