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

Minor bug fix when acls are nil. Also, added support for specifying list of users for grant and revoke as a comma-separated list.

This commit is contained in:
Rupak Ganguly 2012-10-29 17:01:21 -04:00
parent 3274dc6b7c
commit ee2168a855

View file

@ -52,26 +52,38 @@ module Fog
return users
end
def grant(perm, users=[])
r_acl, w_acl = connection.perm_to_acl(perm, users)
unless r_acl.nil?
def grant(perm, users=nil)
# support passing in a list of users in a comma-separated list or as an Array
if users.is_a?(String)
user_list = users.split(',')
else
user_list = users
end
r_acl, w_acl = connection.perm_to_acl(perm, user_list)
unless r_acl.nil? || r_acl.empty?
@read_acl = @read_acl + r_acl
@read_acl.uniq!
end
unless w_acl.nil?
unless w_acl.nil? || w_acl.empty?
@write_acl = @write_acl + w_acl
@write_acl.uniq!
end
true
end
def revoke(perm, users=[])
r_acl, w_acl = connection.perm_to_acl(perm, users)
unless r_acl.nil?
def revoke(perm, users=nil)
# support passing in a list of users in a comma-separated list or as an Array
if users.is_a?(String)
user_list = users.split(',')
else
user_list = users
end
r_acl, w_acl = connection.perm_to_acl(perm, user_list)
unless (r_acl.nil? || r_acl.empty?) && (@read_acl.nil? || @read_acl.empty?)
@read_acl = @read_acl - r_acl
@read_acl.uniq!
end
unless w_acl.nil?
unless (w_acl.nil? || w_acl.empty?) && (@write_acl.nil? || @write_acl.empty?)
@write_acl = @write_acl - w_acl
@write_acl.uniq!
end