Sha256: a1f99419f8842bf4e4002988ccfeaf68c5fcca8b254aa83a66388445dd76a6e2
Contents?: true
Size: 808 Bytes
Versions: 23
Compression:
Stored size: 808 Bytes
Contents
module Kaui class Ability include CanCan::Ability def initialize(user) # user is a Kaui::User object (from Devise) user.permissions.each do |permission| # permission is something like invoice:item_adjust or payment:refund # We rely on a naming convention where the left part refers to a Kaui model model, action = permission.split(':') if model == '*' and action == '*' # All permissions! can :manage, :all elsif model == '*' and action != '*' # TODO elsif action == '*' can :all, ('Kaui::' + model.capitalize).constantize else can action.to_sym, ('Kaui::' + model.capitalize).constantize end end rescue KillBillClient::API::Unauthorized => e end end end
Version data entries
23 entries across 23 versions & 1 rubygems