Class: K3cms::Blog::Ability
- Inherits:
-
Object
- Object
- K3cms::Blog::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/k3cms/blog/ability.rb
Instance Method Summary collapse
-
#initialize(user) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user) ⇒ Ability
Returns a new instance of Ability.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/k3cms/blog/ability.rb', line 6 def initialize(user) if user.k3cms_permitted?(:view_blog_post) can :read, K3cms::Blog::BlogPost, [] do |blog_post| blog_post.published? end end if user.k3cms_permitted?(:edit_blog_post) can :read, K3cms::Blog::BlogPost can :update, K3cms::Blog::BlogPost end if user.k3cms_permitted?(:edit_own_blog_post) can :read, K3cms::Blog::BlogPost can :update, K3cms::Blog::BlogPost, :author_id => user.id end if user.k3cms_permitted?(:create_blog_post) can :create, K3cms::Blog::BlogPost end if user.k3cms_permitted?(:delete_blog_post) can :destroy, K3cms::Blog::BlogPost end if user.k3cms_permitted?(:delete_own_blog_post) can :destroy, K3cms::Blog::BlogPost, :author_id => user.id end end |