racl 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/racl.rb +21 -5
- data/lib/racl/version.rb +1 -1
- metadata +2 -2
data/lib/racl.rb
CHANGED
@@ -1,14 +1,30 @@
|
|
1
1
|
module Racl
|
2
2
|
module ClassMethods
|
3
|
-
|
3
|
+
#
|
4
|
+
# Hooks the Racl into the controller
|
5
|
+
#
|
6
|
+
def protect_with_racl
|
7
|
+
before_filter :racl_check
|
8
|
+
end
|
4
9
|
end
|
5
10
|
|
6
11
|
module InstanceMethods
|
7
|
-
|
12
|
+
#
|
13
|
+
# Checks permissions for a specific action on a specific model
|
14
|
+
# Return true if no acl_model was defined in the acl_models table or
|
15
|
+
# if the user has the privilege on the given model_name
|
16
|
+
#
|
17
|
+
def can privilege, model_name
|
18
|
+
return false unless logged_in?
|
19
|
+
access = true
|
20
|
+
privilege = current_user.privileges.find(:model_name => model_name.to_s, :privilege => privilege.to_s)
|
21
|
+
access = true if privilege
|
22
|
+
access
|
23
|
+
end
|
8
24
|
end
|
9
25
|
|
10
|
-
def self.included(
|
11
|
-
|
12
|
-
|
26
|
+
def self.included(controller)
|
27
|
+
controller.extend ClassMethods
|
28
|
+
controller.send :include, InstanceMethods
|
13
29
|
end
|
14
30
|
end
|
data/lib/racl/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: racl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Emil Kampp
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-13 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: This gem will give you a musch smoother access to different methods both in the controller and view layer.
|