lib/duracloud/space_acls.rb in duracloud-client-0.1.2 vs lib/duracloud/space_acls.rb in duracloud-client-0.1.3

- old
+ new

@@ -1,8 +1,13 @@ module Duracloud class SpaceAcls < Properties + READ = "READ".freeze + WRITE = "WRITE".freeze + + ACL_PREFIX = (PREFIX + "acl-").freeze + def self.property?(prop) space_acl?(prop) end attr_reader :space @@ -18,7 +23,30 @@ def query { storeID: space.store_id } end + def show + each_with_object({}) do |(k, v), memo| + memo[k.sub(ACL_PREFIX, "")] = v + end + end + + def grant(perm, to) + prop = ACL_PREFIX + to + self[prop] = perm + end + + def grant_write(to) + grant WRITE, to + end + + def grant_read(to) + grant READ, to + end + + def revoke(from) + prop = ACL_PREFIX + from + delete prop + end end end