Class: Ddr::Auth::Roles::DetachedRoleSet
- Defined in:
- lib/ddr/auth/roles/detached_role_set.rb
Overview
Wraps a set of Roles detached from a repository object
Instance Attribute Summary collapse
-
#role_set ⇒ Object
writeonly
Sets the attribute role_set.
Attributes inherited from RoleSet
Class Method Summary collapse
-
.deserialize(serialized) ⇒ Object
Deserialize a serialized RoleSet into a DetachedRoleSet.
-
.from_json(json) ⇒ Object
Deserialize a JSON representation of a set of Roles into a DetachedRoleSet.
Instance Method Summary collapse
- #grant(*roles) ⇒ Object
-
#initialize(role_set = Set.new) ⇒ DetachedRoleSet
constructor
A new instance of DetachedRoleSet.
-
#merge(other) ⇒ DetachedRoleSet
Merges the roles from another role set into the role set.
- #revoke(*roles) ⇒ Object
- #revoke_all ⇒ Object
- #to_a ⇒ Object
Methods inherited from RoleSet
#==, #granted, #granted?, #replace, #serialize, #to_json
Constructor Details
#initialize(role_set = Set.new) ⇒ DetachedRoleSet
Returns a new instance of DetachedRoleSet.
28 29 30 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 28 def initialize(role_set = Set.new) super role_set.to_set end |
Instance Attribute Details
#role_set=(value) ⇒ Object (writeonly)
Sets the attribute role_set
26 27 28 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 26 def role_set=(value) @role_set = value end |
Class Method Details
.deserialize(serialized) ⇒ Object
Deserialize a serialized RoleSet into a DetachedRoleSet
15 16 17 18 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 15 def deserialize(serialized) role_set = serialized.map { |role_data| Role.deserialize(role_data) } new(role_set) end |
.from_json(json) ⇒ Object
Deserialize a JSON representation of a set of Roles into a DetachedRoleSet
21 22 23 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 21 def from_json(json) deserialize JSON.parse(json) end |
Instance Method Details
#grant(*roles) ⇒ Object
32 33 34 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 32 def grant(*roles) role_set.merge coerce(roles) end |
#merge(other) ⇒ DetachedRoleSet
Merges the roles from another role set into the role set
51 52 53 54 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 51 def merge(other) role_set.merge other self end |
#revoke(*roles) ⇒ Object
36 37 38 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 36 def revoke(*roles) self.role_set -= coerce(roles) end |
#revoke_all ⇒ Object
40 41 42 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 40 def revoke_all clear end |
#to_a ⇒ Object
44 45 46 |
# File 'lib/ddr/auth/roles/detached_role_set.rb', line 44 def to_a role_set.to_a end |