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.
-
#other_roles ⇒ Object
Returns the value of attribute other_roles.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#system_roles ⇒ Object
Returns the value of attribute system_roles.
Instance Method Summary collapse
- #clean_role(urn_prefix, role) ⇒ Object
-
#initialize(roles = '') ⇒ RoleManager
constructor
A new instance of RoleManager.
- #map_roles ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(roles = '') ⇒ RoleManager
13 14 15 16 17 18 19 20 21 |
# 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) @other_roles = [] map_roles 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 |
#other_roles ⇒ Object
Returns the value of attribute other_roles.
11 12 13 |
# File 'lib/lti_roles.rb', line 11 def other_roles @other_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
#clean_role(urn_prefix, role) ⇒ Object
40 41 42 |
# File 'lib/lti_roles.rb', line 40 def clean_role(urn_prefix, role) role.gsub(urn_prefix, '').gsub('/', '').underscore end |
#map_roles ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lti_roles.rb', line 23 def map_roles roles.split(',').each do |role| case when role.downcase.include?(ContextTypeURN) context_types << clean_role(ContextTypeURN, role) when role.downcase.include?(SystemRoleURN) system_roles << clean_role(SystemRoleURN, role) when role.downcase.include?(InstitutionRoleURN) institution_roles << clean_role(InstitutionRoleURN, role) when role.downcase.include?(ContextRoleURN) context_roles << clean_role(ContextRoleURN, role) else other_roles << role end end end |
#to_h ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/lti_roles.rb', line 44 def to_h { 'roles' => roles, 'context_type' => context_types, 'system_roles' => system_roles, 'institution_roles' => institution_roles, 'context_roles' => context_roles } end |