Class: ApplicationPolicy
Abstract
- Inherits:
-
Object
show all
- Defined in:
- app/policies/application_policy.rb
Overview
This class is abstract.
intended to be subclassed for each ActiveRecord class that needs policy
protection
Base class for Coyote authorization policies. Uses Pundit.
Defined Under Namespace
Classes: Scope
Instance Method Summary
collapse
Constructor Details
#initialize(organization_user, record) ⇒ ApplicationPolicy
Returns a new instance of ApplicationPolicy
8
9
10
11
12
13
|
# File 'app/policies/application_policy.rb', line 8
def initialize(organization_user, record)
raise Pundit::NotAuthorizedError, 'must be logged in' unless organization_user
@organization_user = organization_user
@record = record
end
|
Instance Method Details
#create? ⇒ false
26
27
28
|
# File 'app/policies/application_policy.rb', line 26
def create?
false
end
|
#destroy? ⇒ false
46
47
48
|
# File 'app/policies/application_policy.rb', line 46
def destroy?
false
end
|
#edit? ⇒ false
41
42
43
|
# File 'app/policies/application_policy.rb', line 41
def edit?
update?
end
|
#index? ⇒ false
16
17
18
|
# File 'app/policies/application_policy.rb', line 16
def index?
false
end
|
#new? ⇒ false
31
32
33
|
# File 'app/policies/application_policy.rb', line 31
def new?
create?
end
|
#scope ⇒ ActiveRecord::Base
Returns the scope upon which to base ActiveRecord queries, based on the
class of the record passed in
53
54
55
|
# File 'app/policies/application_policy.rb', line 53
def scope
Pundit.policy_scope!(organization_user, record.class)
end
|
#show? ⇒ false
21
22
23
|
# File 'app/policies/application_policy.rb', line 21
def show?
false
end
|
#update? ⇒ false
36
37
38
|
# File 'app/policies/application_policy.rb', line 36
def update?
false
end
|
#user ⇒ Object
58
59
60
|
# File 'app/policies/application_policy.rb', line 58
def user
organization_user
end
|