Commit 9a0ea135 authored by http://jneen.net/'s avatar http://jneen.net/

factor in global permissions

parent 29440228
...@@ -4,6 +4,8 @@ class BasePolicy ...@@ -4,6 +4,8 @@ class BasePolicy
end end
def self.class_for(subject) def self.class_for(subject)
return GlobalPolicy if subject.nil?
subject.class.ancestors.each do |klass| subject.class.ancestors.each do |klass|
next unless klass.name next unless klass.name
...@@ -59,8 +61,6 @@ class BasePolicy ...@@ -59,8 +61,6 @@ class BasePolicy
private private
def collect_rules(&b) def collect_rules(&b)
return Set.new if @subject.nil?
@can = Set.new @can = Set.new
@cannot = Set.new @cannot = Set.new
yield yield
......
class GlobalPolicy < BasePolicy
def rules
return unless @user
can! :create_group if @user.can_create_group
can! :read_users_list
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment