Class: Ckeditor::PicturePolicy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

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

Returns:

  • (Boolean)


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

def create?
  user.present?
end

#destroy?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


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

def index?
  user.present?
end