diff options
Diffstat (limited to 'lib/permissions/set.rb')
-rw-r--r-- | lib/permissions/set.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/permissions/set.rb b/lib/permissions/set.rb index 14c93ef..0038995 100644 --- a/lib/permissions/set.rb +++ b/lib/permissions/set.rb @@ -1,13 +1,18 @@ AllPermissions = [:create, :update, :destroy, :view, :edit] +# Block will be used to determine chosen permission def one_permission(permission, &block) define_method("#{permission.to_s}_permitted?", &block) end + +# Block will be used to determine chosen permissions def multi_permission(*permission_list, &block) permission_list.flatten.each do |target| one_permission(target, &block) end end + +# Block will be used to determine all permission def single_permission(&block) multi_permission(AllPermissions, &block) end |