rolify 0.1.0 → 0.1.1
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/README.rdoc
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
= rolify
|
|
2
2
|
|
|
3
|
-
Very simple Roles library without any authorization enforcement
|
|
3
|
+
Very simple Roles library without any authorization enforcement supporting scope on resource object.
|
|
4
4
|
|
|
5
5
|
Let's see an example:
|
|
6
6
|
|
|
7
|
-
user.is_moderator?(Forum.first)
|
|
7
|
+
user.is_moderator?(Forum.first)
|
|
8
|
+
=> false # if user is moderator of another Forum
|
|
8
9
|
|
|
9
10
|
This library was intended to be used with CanCan[https://github.com/ryanb/cancan] and devise[https://github.com/plataformatec/devise/] but should be generic enough to be used by any other authentication/authorization solutions.
|
|
10
11
|
|
|
11
|
-
== DISCLAIMER : still in early stage of development. Like a pre-alpha release, kind of ;-) You've been warned !
|
|
12
|
-
|
|
13
|
-
Status:
|
|
14
|
-
|
|
15
|
-
(x) generators
|
|
16
|
-
|
|
17
|
-
(x) migration file
|
|
18
|
-
|
|
19
|
-
( ) specs
|
|
20
|
-
|
|
21
|
-
( ) code
|
|
22
|
-
|
|
23
12
|
== Requirements
|
|
24
13
|
|
|
25
|
-
* >= Rails 3
|
|
14
|
+
* >= Rails 3.1 (rc1 is currently out)
|
|
26
15
|
* ActiveRecord ORM
|
|
27
16
|
|
|
28
17
|
== Installation
|
|
@@ -37,7 +26,7 @@ Alternatively, you can install it as a plugin.
|
|
|
37
26
|
|
|
38
27
|
== Getting Started
|
|
39
28
|
|
|
40
|
-
=== 1. Generate Role
|
|
29
|
+
=== 1. Generate Role Model
|
|
41
30
|
|
|
42
31
|
First, create your Role model and migration file using this generator:
|
|
43
32
|
|
|
@@ -72,15 +61,15 @@ To check if a user has a global role
|
|
|
72
61
|
|
|
73
62
|
user = User.find(1)
|
|
74
63
|
user.has_role? "admin"
|
|
75
|
-
|
|
64
|
+
=> true
|
|
76
65
|
|
|
77
66
|
To check if a user has a role scoped to a resource
|
|
78
67
|
|
|
79
68
|
user = User.find(2)
|
|
80
69
|
user.has_role "moderator", Forum.first
|
|
81
|
-
|
|
70
|
+
=> true
|
|
82
71
|
user.has_role "moderator", Forum.last
|
|
83
|
-
|
|
72
|
+
=> false
|
|
84
73
|
|
|
85
74
|
== Questions or Problems?
|
|
86
75
|
|
|
@@ -88,5 +77,4 @@ If you have any issues with rolify which you cannot find the solution to in the
|
|
|
88
77
|
|
|
89
78
|
== TODO
|
|
90
79
|
|
|
91
|
-
*
|
|
92
|
-
* Write code
|
|
80
|
+
* put syntactic sugar
|
|
@@ -13,7 +13,8 @@ module Rolify
|
|
|
13
13
|
|
|
14
14
|
def generate_role
|
|
15
15
|
template "role.rb", "app/models/role.rb"
|
|
16
|
-
inject_into_class(model_path, user_cname.camelize) do
|
|
16
|
+
inject_into_class(model_path, user_cname.camelize) do
|
|
17
|
+
" include Rolify"
|
|
17
18
|
" has_and_belongs_to_many :#{role_cname.tableize}\n"
|
|
18
19
|
end
|
|
19
20
|
end
|
data/lib/rolify/version.rb
CHANGED