Class: ApplicationPolicy
- Inherits:
-
Object
- Object
- ApplicationPolicy
- Defined in:
- lib/generators/pundit/install/templates/application_policy.rb
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) ⇒ ApplicationPolicy
constructor
A new instance of ApplicationPolicy.
- #new? ⇒ Boolean
- #scope ⇒ Object
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
permalink #initialize(user, record) ⇒ ApplicationPolicy
Returns a new instance of ApplicationPolicy.
4 5 6 7 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 4 def initialize(user, record) @user = user @record = record end |
Instance Attribute Details
permalink #record ⇒ Object (readonly)
Returns the value of attribute record.
2 3 4 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 2 def record @record end |
permalink #user ⇒ Object (readonly)
Returns the value of attribute user.
2 3 4 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 2 def user @user end |
Instance Method Details
permalink #create? ⇒ Boolean
17 18 19 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 17 def create? false end |
permalink #destroy? ⇒ Boolean
33 34 35 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 33 def destroy? false end |
permalink #edit? ⇒ Boolean
29 30 31 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 29 def edit? update? end |
permalink #index? ⇒ Boolean
9 10 11 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 9 def index? false end |
permalink #new? ⇒ Boolean
21 22 23 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 21 def new? create? end |
permalink #scope ⇒ Object
[View source]
37 38 39 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 37 def scope Pundit.policy_scope!(user, record.class) end |
permalink #show? ⇒ Boolean
13 14 15 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 13 def show? scope.where(:id => record.id).exists? end |
permalink #update? ⇒ Boolean
25 26 27 |
# File 'lib/generators/pundit/install/templates/application_policy.rb', line 25 def update? false end |