Class: Ddr::Auth::Roles::Role
- Inherits:
-
Object
- Object
- Ddr::Auth::Roles::Role
- Extended by:
- Deprecation
- Includes:
- Models::Validatable
- Defined in:
- lib/ddr/auth/roles/role.rb
Overview
The assignment of a role to an agent within a scope.
Constant Summary collapse
- DEFAULT_SCOPE =
Roles::RESOURCE_SCOPE
Class Method Summary collapse
Instance Method Summary collapse
- #in_policy_scope? ⇒ Boolean
- #in_resource_scope? ⇒ Boolean
-
#initialize(*args) ⇒ Role
constructor
A new instance of Role.
-
#permissions ⇒ Array<Symbol>
Returns the permissions associated with the role.
- #to_json ⇒ Object
- #to_s ⇒ Object
- #validate! ⇒ Object
Methods included from Models::Validatable
Constructor Details
#initialize(*args) ⇒ Role
Returns a new instance of Role.
35 36 37 38 |
# File 'lib/ddr/auth/roles/role.rb', line 35 def initialize(*args) super validate! end |
Class Method Details
.build(*args) ⇒ Object
25 26 27 28 |
# File 'lib/ddr/auth/roles/role.rb', line 25 def build(*args) Deprecation.warn(Role, "`build` is deprecated; use `new` instead.") new(*args) end |
.from_json(json) ⇒ Object
30 31 32 |
# File 'lib/ddr/auth/roles/role.rb', line 30 def from_json(json) new JSON.parse(json) end |
Instance Method Details
#in_policy_scope? ⇒ Boolean
58 59 60 |
# File 'lib/ddr/auth/roles/role.rb', line 58 def in_policy_scope? scope == Roles::POLICY_SCOPE end |
#in_resource_scope? ⇒ Boolean
54 55 56 |
# File 'lib/ddr/auth/roles/role.rb', line 54 def in_resource_scope? scope == Roles::RESOURCE_SCOPE end |
#permissions ⇒ Array<Symbol>
Returns the permissions associated with the role
64 65 66 |
# File 'lib/ddr/auth/roles/role.rb', line 64 def Roles.type_map[role_type]. end |
#to_json ⇒ Object
44 45 46 |
# File 'lib/ddr/auth/roles/role.rb', line 44 def to_json JSON.dump(to_h) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/ddr/auth/roles/role.rb', line 40 def to_s to_h.to_s end |