diff options
author | http://jneen.net/ <jneen@jneen.net> | 2016-08-12 01:12:52 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2016-08-30 21:35:06 +0300 |
commit | e208765a92748086cacbc56225e827c8463750a5 (patch) | |
tree | be9bb5c39c1b88cb3bab21d05c7a6a07398b4f7e /app/policies/base_policy.rb | |
parent | 5853c96b49010aaf33b85caeb94dfc18873d5656 (diff) |
add policies, and factor out ProjectPolicy
Diffstat (limited to 'app/policies/base_policy.rb')
-rw-r--r-- | app/policies/base_policy.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/policies/base_policy.rb b/app/policies/base_policy.rb new file mode 100644 index 00000000000..3f52b0b005a --- /dev/null +++ b/app/policies/base_policy.rb @@ -0,0 +1,25 @@ +class BasePolicy + def initialize(user, subject) + @user = user + @subject = subject + end + + def abilities + @can = Set.new + @cannot = Set.new + generate! + @can - @cannot + end + + def generate! + raise 'abstract' + end + + def can!(*rules) + @can.merge(rules) + end + + def cannot!(*rules) + @cannot.merge(rules) + end +end |