Class: PandaPal::Session::RoleStore

Inherits:
Object
  • Object
show all
Defined in:
app/models/panda_pal/session.rb

Constant Summary collapse

ContextTypeURN =
'urn:lti:context-type:ims/lis/'.freeze
ROLE_TYPES =
[
  { type: "system", urn: "urn:lti:sysrole:ims/lis/", url: "http://purl.imsglobal.org/vocab/lis/v2/system/person#" },
  { type: "institution", urn: "urn:lti:instrole:ims/lis/", url: "http://purl.imsglobal.org/vocab/lis/v2/institution/person#" },
  { type: "context", urn: "urn:lti:role:ims/lis/", url: "http://purl.imsglobal.org/vocab/lis/v2/membership#" },
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(roles = '') ⇒ RoleStore

Returns a new instance of RoleStore.



114
115
116
117
118
119
120
121
122
123
# File 'app/models/panda_pal/session.rb', line 114

def initialize(roles = '')
  roles = roles.split(',') if roles.is_a?(String)
  @roles = roles || []

  @context_types = []
  @other_roles = []
  @parsed_roles = HashWithIndifferentAccess.new

  map_roles
end

Instance Attribute Details

#context_typesObject

Returns the value of attribute context_types.



112
113
114
# File 'app/models/panda_pal/session.rb', line 112

def context_types
  @context_types
end

#other_rolesObject

Returns the value of attribute other_roles.



112
113
114
# File 'app/models/panda_pal/session.rb', line 112

def other_roles
  @other_roles
end

#rolesObject

Returns the value of attribute roles.



112
113
114
# File 'app/models/panda_pal/session.rb', line 112

def roles
  @roles
end

Instance Method Details

#context_rolesObject



127
# File 'app/models/panda_pal/session.rb', line 127

def context_roles; @parsed_roles[:context] || []; end

#institution_rolesObject



126
# File 'app/models/panda_pal/session.rb', line 126

def institution_roles; @parsed_roles[:institution] || []; end

#system_rolesObject



125
# File 'app/models/panda_pal/session.rb', line 125

def system_roles; @parsed_roles[:system] || []; end

#to_hObject



129
130
131
132
133
134
135
136
137
# File 'app/models/panda_pal/session.rb', line 129

def to_h
  {
    'roles' => roles,
    'context_type' => context_types,
    'system_roles' => system_roles,
    'institution_roles' => institution_roles,
    'context_roles' => context_roles
  }
end