Class: Ckeditor::PicturePolicy
- Inherits:
-
Object
- Object
- Ckeditor::PicturePolicy
- Defined in:
- lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb
Instance Attribute Summary collapse
-
#picture ⇒ Object
readonly
Returns the value of attribute picture.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, picture) ⇒ PicturePolicy
constructor
A new instance of PicturePolicy.
Constructor Details
#initialize(user, picture) ⇒ PicturePolicy
Returns a new instance of PicturePolicy.
4 5 6 7 |
# File 'lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb', line 4 def initialize(user, picture) @user = user @picture = picture end |
Instance Attribute Details
#picture ⇒ Object (readonly)
Returns the value of attribute picture.
2 3 4 |
# File 'lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb', line 2 def picture @picture end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
2 3 4 |
# File 'lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb', line 2 def user @user end |
Instance Method Details
#create? ⇒ Boolean
13 14 15 |
# File 'lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb', line 13 def create? user.present? end |
#destroy? ⇒ Boolean
17 18 19 |
# File 'lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb', line 17 def destroy? picture.assetable_id == user.id end |
#index? ⇒ Boolean
9 10 11 |
# File 'lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb', line 9 def index? user.present? end |