Sha256: 20cfe9eacd3030020cf7b8a577e3a19434593e45f67d2028e75363c5e7cb9f63

Contents?: true

Size: 800 Bytes

Versions: 7

Compression:

Stored size: 800 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    alias_action :destroy, :to => :delete

    @user = user

    if @user
      case @user.user_role_type.id
        when ::UserRoleType.default.id then default
        when ::UserRoleType.redactor.id then redactor
        when ::UserRoleType.moderator.id then moderator
        when ::UserRoleType.admin.id then admin
      end
    else
      guest
    end
  end

  def guest
  end

  def default
    guest
  end

  def redactor
    default
  end

  def moderator
    default
    can :manage, Dashboard
    can [:read, :create], AdminComment
    can :destroy, AdminComment, :author_id => @user.id
    cannot :destroy, User, :id => @user.id
  end

  def admin
    can :manage, :all

    cannot :destroy, User, :id => @user.id
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.2.3 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.2.2 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.2.1 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.2.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.1.2 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.1.1 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.1.0 lib/generators/ab_admin/install/templates/models/ability.rb