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