diff options
author | Wei Xie <xieconnect@gmail.com> | 2010-06-06 10:14:09 +0800 |
---|---|---|
committer | Hans de Graaff <hans@degraaff.org> | 2010-07-25 09:08:51 +0200 |
commit | 854029152445e65fa67a59d49721801a8ee654df (patch) | |
tree | 4f489226a6e7e45ed8246f55b6b031a7246b2854 /lib | |
parent | import User data from db:seed (diff) | |
download | council-webapp-854029152445e65fa67a59d49721801a8ee654df.tar.gz council-webapp-854029152445e65fa67a59d49721801a8ee654df.tar.bz2 council-webapp-854029152445e65fa67a59d49721801a8ee654df.zip |
Agenda implemented and tested
Diffstat (limited to 'lib')
-rw-r--r-- | lib/permission.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/permission.rb b/lib/permission.rb new file mode 100644 index 0000000..9a68a8e --- /dev/null +++ b/lib/permission.rb @@ -0,0 +1,16 @@ +# methods one_permission and multi_permission are originally authored by ahenobarbi. +# Refer to http://github.com/ahenobarbi/Gentoo-Recruiters-App/blob/master/lib/permissions/set.rb + +def one_permission(permission, &block) + define_method("#{permission.to_s}_permitted?", &block) +end + +def multi_permission(*permission_list, &block) + permission_list.flatten.each do |target| + one_permission(target, &block) + end +end + +def permitted_for_roles(*roles) + acting_user.signed_up? and roles.flatten.include?(acting_user.role.to_sym) +end |