Class: Ddr::Auth::Roles::PropertyRoleSet

Inherits:
RoleSet
  • Object
show all
Defined in:
lib/ddr/auth/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, #granted?, #initialize, #replace, #serialize, #to_json

Constructor Details

This class inherits a constructor from Ddr::Auth::Roles::RoleSet

Instance Method Details

#each(&block) ⇒ Object



35
36
37
# File 'lib/ddr/auth/roles/property_role_set.rb', line 35

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

#grant(*roles) ⇒ Object



9
10
11
12
13
# File 'lib/ddr/auth/roles/property_role_set.rb', line 9

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.



18
19
20
21
22
23
24
# File 'lib/ddr/auth/roles/property_role_set.rb', line 18

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.



30
31
32
33
# File 'lib/ddr/auth/roles/property_role_set.rb', line 30

def revoke_all
  each(&:destroy)
  self
end

#to_setObject



39
40
41
# File 'lib/ddr/auth/roles/property_role_set.rb', line 39

def to_set
  map.to_set
end