Class: PackagesPolicy

Inherits:
CollectionPolicy show all
Defined in:
app/policies/packages_policy.rb

Instance Attribute Summary

Attributes inherited from CollectionPolicy

#user

Instance Method Summary collapse

Methods inherited from CollectionPolicy

#authorize!, #initialize

Constructor Details

This class inherits a constructor from CollectionPolicy

Instance Method Details

#base_scopeObject


13
14
15
# File 'app/policies/packages_policy.rb', line 13

def base_scope
  Package.all
end

#create?Boolean

Returns:

  • (Boolean)

9
10
11
# File 'app/policies/packages_policy.rb', line 9

def create?
  user.known?
end

#index?Boolean

Returns:

  • (Boolean)

5
6
7
# File 'app/policies/packages_policy.rb', line 5

def index?
  user.known?
end

#resolveObject


17
18
19
20
21
22
23
24
25
# File 'app/policies/packages_policy.rb', line 17

def resolve
  if user.admin?
    scope.all
  elsif user.known?
    scope.owned(user.id)
  else
    scope.none
  end
end