blob: 0038995358ff91e7f0a28a6b566a643d0ec557eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
|