Class: Dscf::Core::ApplicationPolicy::Scope

Inherits:
Object
  • Object
show all
Defined in:
app/policies/dscf/core/application_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

Returns a new instance of Scope.



34
35
36
37
# File 'app/policies/dscf/core/application_policy.rb', line 34

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

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



32
33
34
# File 'app/policies/dscf/core/application_policy.rb', line 32

def scope
  @scope
end

#userObject (readonly)

Returns the value of attribute user.



32
33
34
# File 'app/policies/dscf/core/application_policy.rb', line 32

def user
  @user
end

Instance Method Details

#resolveObject



39
40
41
42
43
44
# File 'app/policies/dscf/core/application_policy.rb', line 39

def resolve
  return scope.all if user.super_admin?
  return scope.none unless user.has_permission?(index_permission_code)

  scope.all
end