Class: Ddr::Auth::Roles::PropertyRoleSet
- 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
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #grant(*roles) ⇒ Object
- #revoke(*roles) ⇒ Object
- #revoke_all ⇒ Object
- #to_set ⇒ Object
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_all ⇒ Object
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_set ⇒ Object
39 40 41 |
# File 'lib/ddr/auth/roles/property_role_set.rb', line 39 def to_set map.to_set end |