Class: G5Authenticatable::BasePolicy::BaseScope

Inherits:
Object
  • Object
show all
Defined in:
app/policies/g5_authenticatable/base_policy.rb

Overview

Base class for all authorization scopes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ BaseScope

Returns a new instance of BaseScope.



50
51
52
53
# File 'app/policies/g5_authenticatable/base_policy.rb', line 50

def initialize(user, scope)
  @user = user
  @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



48
49
50
# File 'app/policies/g5_authenticatable/base_policy.rb', line 48

def scope
  @scope
end

#userObject (readonly)

Returns the value of attribute user.



48
49
50
# File 'app/policies/g5_authenticatable/base_policy.rb', line 48

def user
  @user
end

Instance Method Details

#global_role?Boolean Also known as: has_global_role?

Returns:

  • (Boolean)


63
64
65
# File 'app/policies/g5_authenticatable/base_policy.rb', line 63

def global_role?
  G5Authenticatable::BasePolicy.new(user, nil).global_role?
end

#resolveObject



55
56
57
58
59
60
61
# File 'app/policies/g5_authenticatable/base_policy.rb', line 55

def resolve
  if user.has_role?(:super_admin)
    scope.all
  else
    scope.none
  end
end