Class: Itsf::Backend::BasePolicy
- Inherits:
-
Object
- Object
- Itsf::Backend::BasePolicy
- Defined in:
- app/policies/itsf/backend/base_policy.rb
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, record) ⇒ BasePolicy
constructor
A new instance of BasePolicy.
- #new? ⇒ Boolean
- #scope ⇒ Object
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, record) ⇒ BasePolicy
Returns a new instance of BasePolicy.
5 6 7 8 |
# File 'app/policies/itsf/backend/base_policy.rb', line 5 def initialize(user, record) @user = user @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
3 4 5 |
# File 'app/policies/itsf/backend/base_policy.rb', line 3 def record @record end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/policies/itsf/backend/base_policy.rb', line 3 def user @user end |
Instance Method Details
#create? ⇒ Boolean
20 21 22 23 |
# File 'app/policies/itsf/backend/base_policy.rb', line 20 def create? # false (user, record, __method__) end |
#destroy? ⇒ Boolean
38 39 40 41 |
# File 'app/policies/itsf/backend/base_policy.rb', line 38 def destroy? # false (user, record, __method__) end |
#edit? ⇒ Boolean
34 35 36 |
# File 'app/policies/itsf/backend/base_policy.rb', line 34 def edit? update? end |
#index? ⇒ Boolean
10 11 12 13 |
# File 'app/policies/itsf/backend/base_policy.rb', line 10 def index? # false (user, record, __method__) end |
#new? ⇒ Boolean
25 26 27 |
# File 'app/policies/itsf/backend/base_policy.rb', line 25 def new? create? end |
#scope ⇒ Object
43 44 45 |
# File 'app/policies/itsf/backend/base_policy.rb', line 43 def scope Pundit.policy_scope!(user, record.class) end |
#show? ⇒ Boolean
15 16 17 18 |
# File 'app/policies/itsf/backend/base_policy.rb', line 15 def show? # scope.where(id: record.id).exists? (user, record, __method__) end |
#update? ⇒ Boolean
29 30 31 32 |
# File 'app/policies/itsf/backend/base_policy.rb', line 29 def update? # false (user, record, __method__) end |