Class: Ckeditor::AttachmentFilePolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, attachment)
  @user = user
  @attachment = attachment
end

Instance Attribute Details

#attachmentObject (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
  @attachment
end

#userObject (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb', line 13

def create?
  user.present?
end

#destroy?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb', line 17

def destroy?
  attachment.assetable_id == user.id
end

#index?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb', line 9

def index?
  user.present?
end