Class: LeanCms::PostPolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/lean_cms/post_policy.rb

Defined Under Namespace

Classes: Scope

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#record, #user

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#edit?, #initialize, #new?

Constructor Details

This class inherits a constructor from LeanCms::ApplicationPolicy

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/policies/lean_cms/post_policy.rb', line 13

def create?
  user.can_edit_blog?
end

#destroy?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/policies/lean_cms/post_policy.rb', line 23

def destroy?
  update?
end

#index?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/policies/lean_cms/post_policy.rb', line 5

def index?
  user.can_edit_blog?
end

#show?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/policies/lean_cms/post_policy.rb', line 9

def show?
  user.can_edit_blog?
end

#update?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'app/policies/lean_cms/post_policy.rb', line 17

def update?
  return false unless user.can_edit_blog?
  # Super admins can edit any post, others can only edit their own
  user.is_super_admin? || record.author_id == user.id
end