Method: JunglePath::API::Helpers::AuthLocalUser#get_roles

Defined in:
lib/jungle_path/api/helpers/auth_local_user.rb

#get_roles(key, no_cache = false) ⇒ Object



166
167
168
169
170
171
172
173
174
175
# File 'lib/jungle_path/api/helpers/auth_local_user.rb', line 166

def get_roles key, no_cache=false
  return nil unless key
  cache_key = "#{key.id}_roles"
  roles = cache.get(cache_key)
  if roles == nil or no_cache
    roles = SQL::Role.by_user(db, key)
    cache.set cache_key, roles if roles
  end
  roles
end