role_authorization 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -26,8 +26,12 @@ RoleAuthorization::Rules.define :user do
|
|
26
26
|
else
|
27
27
|
if options[:resource]
|
28
28
|
check_method = options[:check] || :id
|
29
|
-
|
30
|
-
|
29
|
+
resource_instances = controller_instance.instance_eval(&options[:resource])
|
30
|
+
resource_instances = [resources_instances] unless resource_instances.is_a?(Array)
|
31
|
+
|
32
|
+
resource_instances.map do |resource_instance|
|
33
|
+
controller_instance.current_user.id == resource_instance.try(check_method)
|
34
|
+
end.include?(true)
|
31
35
|
else
|
32
36
|
false
|
33
37
|
end
|