Method: JunglePath::API::Helpers::AuthLocalUser#zget_roles

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

#zget_roles(no_cache = false) ⇒ Object



177
178
179
180
181
182
183
184
185
186
# File 'lib/jungle_path/api/helpers/auth_local_user.rb', line 177

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