simple_acl 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -13
- data/lib/simple_acl/acl.rb +1 -1
- data/lib/simple_acl/configuration.rb +0 -10
- data/lib/simple_acl/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -73,7 +73,11 @@ Example:
|
|
73
73
|
```
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
acl_role(:guest,
|
76
|
+
acl_role(:guest,
|
77
|
+
privileges: {
|
78
|
+
show: true
|
79
|
+
}
|
80
|
+
)
|
77
81
|
```
|
78
82
|
|
79
83
|
### Define assertions in your ACL
|
@@ -89,7 +93,7 @@ Example:
|
|
89
93
|
|
90
94
|
```ruby
|
91
95
|
acl_guest privileges: {
|
92
|
-
show: lambda{|
|
96
|
+
show: lambda{|values| YourModel.find(values[:id]).guest_access?}
|
93
97
|
}
|
94
98
|
|
95
99
|
```
|
@@ -98,21 +102,11 @@ If you have values containing `params` and your user model `current_user`
|
|
98
102
|
|
99
103
|
```ruby
|
100
104
|
acl_user privileges: {
|
101
|
-
update: lambda{|
|
105
|
+
update: lambda{|values| values[:current_user].profile_id == values[:params][:id]}
|
102
106
|
}
|
103
107
|
|
104
108
|
```
|
105
109
|
|
106
|
-
## Configuration
|
107
|
-
|
108
|
-
In an initializer, you can specify the role you want to use.
|
109
|
-
(defaults are :admin, :user, :guest)
|
110
|
-
|
111
|
-
```
|
112
|
-
SimpleAcl::Configuration.authorized_roles = [:admin, :user]
|
113
|
-
|
114
|
-
```
|
115
|
-
|
116
110
|
## Contributing
|
117
111
|
|
118
112
|
1. Fork it
|
data/lib/simple_acl/acl.rb
CHANGED
@@ -27,7 +27,7 @@ module SimpleAcl
|
|
27
27
|
return authorized if assertion.class == TrueClass
|
28
28
|
|
29
29
|
if assertion.class == Proc && assertion.lambda?
|
30
|
-
assertion_result = assertion.call(
|
30
|
+
assertion_result = assertion.call(values)
|
31
31
|
return assert(assertion_result, current_role, values)
|
32
32
|
end
|
33
33
|
|
@@ -1,14 +1,6 @@
|
|
1
1
|
module SimpleAcl
|
2
2
|
class Configuration
|
3
3
|
|
4
|
-
class << self
|
5
|
-
attr_writer :authorized_roles
|
6
|
-
|
7
|
-
def authorized_roles
|
8
|
-
@authorized_roles ||= [:admin, :user, :guest]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
4
|
attr_reader :acl_privileges
|
13
5
|
|
14
6
|
def initialize
|
@@ -16,8 +8,6 @@ module SimpleAcl
|
|
16
8
|
end
|
17
9
|
|
18
10
|
def add_role(role, privileges)
|
19
|
-
raise ExceptionConfiguration, ExceptionConfiguration, "Unauthorized role #{role}" unless self.class.authorized_roles.include?(role)
|
20
|
-
|
21
11
|
check_keys(privileges)
|
22
12
|
|
23
13
|
@acl_privileges[role] = (@acl_privileges[privileges[:inherit]] || {}).merge(privileges[:privileges] || {})
|
data/lib/simple_acl/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_acl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|