Class: LTIRoles::RoleManager
- Inherits:
-
Object
- Object
- LTIRoles::RoleManager
- Defined in:
- lib/lti_roles.rb
Instance Attribute Summary collapse
-
#context_roles ⇒ Object
Returns the value of attribute context_roles.
-
#context_types ⇒ Object
Returns the value of attribute context_types.
-
#institution_roles ⇒ Object
Returns the value of attribute institution_roles.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#system_roles ⇒ Object
Returns the value of attribute system_roles.
Instance Method Summary collapse
-
#initialize(roles = '') ⇒ RoleManager
constructor
A new instance of RoleManager.
- #map_roles(urn_prefix) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(roles = '') ⇒ RoleManager
Returns a new instance of RoleManager.
13 14 15 16 17 18 19 |
# File 'lib/lti_roles.rb', line 13 def initialize(roles = '') @roles = roles @context_types = map_roles(ContextTypeURN) @system_roles = map_roles(SystemRoleURN) @institution_roles = map_roles(InstitutionRoleURN) @context_roles = map_roles(ContextRoleURN) end |
Instance Attribute Details
#context_roles ⇒ Object
Returns the value of attribute context_roles.
11 12 13 |
# File 'lib/lti_roles.rb', line 11 def context_roles @context_roles end |
#context_types ⇒ Object
Returns the value of attribute context_types.
11 12 13 |
# File 'lib/lti_roles.rb', line 11 def context_types @context_types end |
#institution_roles ⇒ Object
Returns the value of attribute institution_roles.
11 12 13 |
# File 'lib/lti_roles.rb', line 11 def institution_roles @institution_roles end |
#roles ⇒ Object
Returns the value of attribute roles.
11 12 13 |
# File 'lib/lti_roles.rb', line 11 def roles @roles end |
#system_roles ⇒ Object
Returns the value of attribute system_roles.
11 12 13 |
# File 'lib/lti_roles.rb', line 11 def system_roles @system_roles end |
Instance Method Details
#map_roles(urn_prefix) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/lti_roles.rb', line 21 def map_roles(urn_prefix) roles.split(',').map do |role| next unless role.include?(urn_prefix) role.gsub(urn_prefix, '').gsub('/', '').underscore end.compact end |
#to_h ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/lti_roles.rb', line 28 def to_h { 'roles' => roles, 'context_type' => context_types, 'system_roles' => system_roles, 'institution_roles' => institution_roles, 'context_roles' => context_roles } end |