From 8fd2700a2ac84d66f6272a270719923e6d7c37ae Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Wed, 13 Jul 2011 19:27:58 -0400 Subject: [PATCH] Add an acl property that will allow setting of acls strings. Also, add fix the public property to now toggle the appropriate acl string. --- lib/fog/storage/models/hp/directory.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/fog/storage/models/hp/directory.rb b/lib/fog/storage/models/hp/directory.rb index b95baf8cb..12884fdd1 100644 --- a/lib/fog/storage/models/hp/directory.rb +++ b/lib/fog/storage/models/hp/directory.rb @@ -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