README.rdoc in rolify-2.2.2 vs README.rdoc in rolify-3.0.0
- old
+ new
@@ -1,6 +1,6 @@
-= rolify {<img src="https://secure.travis-ci.org/EppO/rolify.png?branch=v3">}[http://travis-ci.org/EppO/rolify] {<img src="https://gemnasium.com/EppO/rolify.png">}[https://gemnasium.com/EppO/rolify]
+= rolify {<img src="https://secure.travis-ci.org/EppO/rolify.png?branch=master">}[http://travis-ci.org/EppO/rolify] {<img src="https://gemnasium.com/EppO/rolify.png">}[https://gemnasium.com/EppO/rolify]
Very simple Roles library without any authorization enforcement supporting scope on resource object.
Let's see an example:
@@ -10,11 +10,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
-* ActiveRecord ORM
+* ActiveRecord ORM <b>or</b> Mongoid
* supports ruby 1.8/1.9, REE, JRuby and Rubinius
== Installation
In <b>Rails 3</b>, add this to your Gemfile and run the +bundle+ command.
@@ -34,12 +34,14 @@
rails g rolify:role Role User
Role and User classes are the default. You can specify any Role class name you want. This is completly a new file so any name can do the job.
For the User class name, you would probably use the one provided by your authentication solution. rolify just adds some class methods in an existing User class.
-=== 2. Run the migration
+If you want to use Mongoid instead of ActiveRecord, follow these instructions[https://github.com/EppO/rolify/wiki/Configuration], and skip to step #3
+=== 2. Run the migration (only required when using ActiveRecord)
+
Let's migrate !
rake db:migrate
=== 3. Add a role to a user
@@ -97,10 +99,40 @@
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].
+=== 5. Resource roles querying
+
+Starting from rolify 3.0, you can search roles on instance level or class level resources.
+
+==== Instance level
+
+ forum = Forum.first
+ forum.roles
+ # => [ list of roles that are only binded to forum instance ]
+ forum.applied_roles
+ # => [ list of roles binded to forum instance and to the Forum class ]
+
+==== Class level
+
+ Forum.with_role("admin")
+ # => [ list of Forum instances that has role "admin" binded to it ]
+ Forum.with_role("admin", current_user)
+ # => [ list of Forum instances that has role "admin" binded to it and belongs to current_user roles ]
+
+ Forum.find_roles
+ # => [ list of roles that binded to any Forum instance or to the Forum class ]
+ Forum.find_roles("admin")
+ # => [ list of roles that binded to any Forum instance or to the Forum class with "admin" as a role name ]
+ Forum.find_roles("admin", current_user)
+ # => [ list of roles that binded to any Forum instance or to the Forum class with "admin" as a role name and belongs to current_user roles ]
+
+== Resources
+
+* {Wiki}[https://github.com/EppO/rolify/wiki]
+* {Usage}[https://github.com/EppO/rolify/wiki/Usage]: all the available commands
+* {Tutorial}[https://github.com/EppO/rolify/wiki/Tutorial]: 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.
\ No newline at end of file