factor in global permissions

This commit is contained in:
http://jneen.net/ 2016-08-16 16:29:19 -07:00
parent 2944022835
commit 9a0ea13501
2 changed files with 9 additions and 2 deletions

View file

@ -4,6 +4,8 @@ class BasePolicy
end
def self.class_for(subject)
return GlobalPolicy if subject.nil?
subject.class.ancestors.each do |klass|
next unless klass.name
@ -59,8 +61,6 @@ class BasePolicy
private
def collect_rules(&b)
return Set.new if @subject.nil?
@can = Set.new
@cannot = Set.new
yield

View file

@ -0,0 +1,7 @@
class GlobalPolicy < BasePolicy
def rules
return unless @user
can! :create_group if @user.can_create_group
can! :read_users_list
end
end