0.0
No commit activity in last 3 years
No release in over 3 years
Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Gem Version

CanCan-Sugar

Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.

Installation

$ gem install cancan-sugar

Gemfile

gem "cancan-sugar"

Usage

class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= User.new

    permissions_for user, as: :admin do
      can :manage, :all
    end

    permissions_for user, as: [:manager, :user] do
      can :update, User, id: user.id
      can :read, Document
      can :update, Document, user_id: user.id
      can :create, Document
    end
    
    permissions_for user, as: :manager do
      can :comment, Document
      can :create, Comment
      can :create, DocumentComment
      can :create, Incedent
      can :update, Incedent, initiator_id: user.id
    end

  end
end

License

(C)opyLeft & (C)odeRight Alexey Kolosov aka mr.huNTer alexey.kolosov@gmail.com

"CanCan-Sugar" released without warranty under the terms of the Artistic License 2.0 http://www.opensource.org/licenses/artistic-license-2.0