Sha256: ec87b8095ab25712dd88b8d25442cec0ef239492f532f082e8d432ad4b827c89

Contents?: true

Size: 899 Bytes

Versions: 8

Compression:

Stored size: 899 Bytes

Contents

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

    def initialize(space)
      super()
      @space = space
      if space.persisted?
        response = Client.get_space_acls(space.space_id, **query)
        update filter(response.headers)
      end
    end

    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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
duracloud-client-0.6.0 lib/duracloud/space_acls.rb
duracloud-client-0.5.0 lib/duracloud/space_acls.rb
duracloud-client-0.4.0 lib/duracloud/space_acls.rb
duracloud-client-0.3.0 lib/duracloud/space_acls.rb
duracloud-client-0.2.0 lib/duracloud/space_acls.rb
duracloud-client-0.1.5 lib/duracloud/space_acls.rb
duracloud-client-0.1.4 lib/duracloud/space_acls.rb
duracloud-client-0.1.3 lib/duracloud/space_acls.rb