lib/can_play/ability.rb in can_play-0.2.4 vs lib/can_play/ability.rb in can_play-0.2.5
- old
+ new
@@ -3,15 +3,15 @@
attr_accessor :user
def initialize(user)
self.user = user||CanPlay::Config.user_class_name.constantize.new
CanPlay::Config.super_roles.each do |role_name|
- can(:manage, :all) if user.role?(role_name)
+ can(:manage, :all) if user.send(CanPlay::Config.role_judge_method, role_name)
end
CanPlay::Config.role_class_name.constantize.all.each do |role|
next unless user.role?(role.name)
role.send(CanPlay::Config.role_resources_relation_name).each do |role_resource|
- resource = CanPlay.find_by_name(role_resource.resource_name)
+ resource = CanPlay.find_by_name_and_code(role_resource.resource_name, CanPlay.override_code)
next unless resource
if resource[:type] == 'collection'
if resource[:behavior]
block = resource[:behavior]
can(resource[:verb], resource[:object]) if block.call(user)
\ No newline at end of file