diff options
author | http://jneen.net/ <jneen@jneen.net> | 2016-08-16 21:10:34 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2016-08-30 21:39:22 +0300 |
commit | 4d904bf3521b4600db228c48214f3892e86ac72a (patch) | |
tree | 098b9c292e5b8ff1b1296a4a5aed20127124ec8f /app/policies/base_policy.rb | |
parent | 1ca9b3354a350b83d1e025b3d46280bc5bb60f2b (diff) |
port issues to Issu{able,e}Policy
Diffstat (limited to 'app/policies/base_policy.rb')
-rw-r--r-- | app/policies/base_policy.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/policies/base_policy.rb b/app/policies/base_policy.rb index 10ce38329c4..fd5d05a1bd1 100644 --- a/app/policies/base_policy.rb +++ b/app/policies/base_policy.rb @@ -3,6 +3,10 @@ class BasePolicy new(user, subject).abilities end + def self.class_for(subject) + "#{subject.class.name}Policy".constantize + end + attr_reader :user, :subject def initialize(user, subject) @user = user @@ -18,8 +22,12 @@ class BasePolicy collect_rules { anonymous_rules } end - def generate! - raise 'abstract' + def anonymous_rules + rules + end + + def delegate!(new_subject) + @can.merge(BasePolicy.class_for(new_subject).abilities(@user, new_subject)) end def can!(*rules) |