Sha256: 3a287273b77f9c2d39c4f80f331023787ce056ee19f233a7061a7206058b02b9
Contents?: true
Size: 649 Bytes
Versions: 1
Compression:
Stored size: 649 Bytes
Contents
class Ability include CanCan::Ability def self.role_permits @role_permits if @role_permits # use inject ? @role_permits ||= [] ['Admin', 'User', 'Author'].each do |role| # set up each RolePermit instance to share this same Ability so that the can and cannot operations work on the same permission collection! @role_permits << Kernel.const_get("RolePermit::#{role}").new(self) end @role_permits end def initialize(user, request) # put ability logic here! user ||= User.new # guest Ability.role_permits.each{|rp| rp.permit?(user, request) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
auth-assistant-0.4.0 | lib/generators/auth_assist/templates/ability.rb |