Class: AccessRoles::PropertyRoleSet

Inherits:
RoleSet
  • Object
show all
Defined in:
lib/access_roles/property_role_set.rb

Overview

Wraps a set of Roles implemented as an ActiveTriples::Term.

Instance Attribute Summary

Attributes inherited from RoleSet

#role_set

Instance Method Summary collapse

Methods inherited from RoleSet

#==, #granted?, #initialize, #replace, #serialize, #to_json

Constructor Details

This class inherits a constructor from AccessRoles::RoleSet

Instance Method Details

#each(&block) ⇒ Object


33
34
35
# File 'lib/access_roles/property_role_set.rb', line 33

def each(&block)
  role_set.map.each(&block)
end

#grant(*roles) ⇒ Object


7
8
9
10
11
# File 'lib/access_roles/property_role_set.rb', line 7

def grant(*roles)
  if roles.present?
    role_set << coerce(roles)
  end
end

#revoke(*roles) ⇒ Object

Note:

We have to destroy resources on the ActiveTriples::Term because Term#delete does not support isomorphism.


16
17
18
19
20
21
22
# File 'lib/access_roles/property_role_set.rb', line 16

def revoke(*roles)
  coerce(roles).each do |role|
    if role_index = find_index(role)
      role_set[role_index].destroy
    end
  end
end

#revoke_allObject

Note:

We have to destroy resources on the ActiveTriples::Term because Term#delete does not support isomorphism.


28
29
30
31
# File 'lib/access_roles/property_role_set.rb', line 28

def revoke_all
  each(&:destroy)
  self
end

#to_setObject


37
38
39
# File 'lib/access_roles/property_role_set.rb', line 37

def to_set
  map.to_set
end