Class Authorize
In: app/helpers/authorize.rb
Parent: Object

Methods

Included Modules

Singleton

Public Class methods

[Source]

    # File app/helpers/authorize.rb, line 6
 6:   def self.authorizations(role)
 7:     if @@AUTHORIZATIONS.nil?
 8:       @@AUTHORIZATIONS = Hash.new
 9:       @@AUTHORIZATIONS[UserRole::USER_ROLE_ROOT]  = [UserRole::USER_ROLE_ROOT,  UserRole::USER_ROLE_ADMIN, UserRole::USER_ROLE_USER]
10:       @@AUTHORIZATIONS[UserRole::USER_ROLE_ADMIN] = [UserRole::USER_ROLE_ADMIN, UserRole::USER_ROLE_USER]
11:       @@AUTHORIZATIONS[UserRole::USER_ROLE_USER]  = [UserRole::USER_ROLE_USER]
12:     end
13:     @@AUTHORIZATIONS[role]
14:   end

[Source]

    # File app/helpers/authorize.rb, line 16
16:   def self.is_role_allowed_for_current_user?(role)
17:     return self.is_role_allowed_for_user?(current_user, role)
18:   end

[Source]

    # File app/helpers/authorize.rb, line 20
20:   def self.is_role_allowed_for_user?(user, role)
21:     if user
22:       return self.authorizations(user.user_role.role).include?(role)
23:     end
24:     return false
25:   end

[Validate]