README.rdoc in rolify-1.0.0 vs README.rdoc in rolify-1.1.0
- old
+ new
@@ -1,6 +1,6 @@
-= rolify http://travis-ci.org/EppO/rolify.png
+= rolify {<img src="https://secure.travis-ci.org/EppO/rolify.png">}[http://travis-ci.org/EppO/rolify]
Very simple Roles library without any authorization enforcement supporting scope on resource object.
Let's see an example:
user.has_role?("moderator", Forum.first)
@@ -8,11 +8,11 @@
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.
== Requirements
-* >= Rails 3.1 (rc4 is currently out)
+* >= Rails 3.1
* ActiveRecord ORM
== Installation
In <b>Rails 3</b>, add this to your Gemfile and run the +bundle+ command.
@@ -45,15 +45,20 @@
To define a global role:
user = User.find(1)
user.has_role "admin"
-To define a role scoped to a resource
+To define a role scoped to a resource instance
user = User.find(2)
user.has_role "moderator", Forum.first
+To define a role scoped to a resource class
+
+ user = User.find(3)
+ user.has_role "moderator", Forum
+
That's it !
=== 4. Check roles
To check if a user has a global role:
@@ -61,33 +66,39 @@
user = User.find(1)
user.has_role "admin" # sets a global role
user.has_role? "admin"
=> true
-To check if a user has a role scoped to a resource:
+To check if a user has a role scoped to a resource instance:
user = User.find(2)
- user.has_role "moderator", Forum.first # sets a role scoped to a resource
+ user.has_role "moderator", Forum.first # sets a role scoped to a resource instance
user.has_role? "moderator", Forum.first
=> true
user.has_role? "moderator", Forum.last
=> false
-A global role overrides resource role request:
+To check if a user has a role scoped to a resource class:
user = User.find(3)
+ user.has_role "moderator", Forum # sets a role scoped to a resource class
+ user.has_role? "moderator", Forum
+ => true
+ user.has_role? "moderator", Forum.first
+ => true
+ user.has_role? "moderator", Forum.last
+ => true
+
+A global role overrides resource role request:
+
+ user = User.find(4)
user.has_role "moderator" # sets a global role
user.has_role? "moderator", Forum.first
=> true
user.has_role? "moderator", Forum.last
=> true
Please see on {the wiki}[https://github.com/EppO/rolify/wiki/Usage] for all the available commands and the {Tutorial}[https://github.com/EppO/rolify/wiki/Tutorial] to understand how to use {rolify}[http://eppo.github.com/rolify] with {Devise}[https://github.com/plataformatec/devise] and {CanCan}[https://github.com/ryanb/cancan].
== Questions or Problems?
-If you have any issue or feature request with/for rolify, please add an {issue on GitHub}[https://github.com/EppO/rolify/issues] or fork the project and send a pull request.
-
-== TODO
-
-* complete tests coverage
-* performance enhancements
+If you have any issue or feature request with/for rolify, please add an {issue on GitHub}[https://github.com/EppO/rolify/issues] or fork the project and send a pull request.
\ No newline at end of file