Rolex
Redis-backed roles for Rails applications.
To use in a Rails application
Create an initializer:
Rolex.redis = (Redis.current || ENV['REDISTOGO_URL'] || whatever)
Include Rolex into your model:
class User < ActiveRecord::Base
include Rolex
end
Then:
> user.add_role :admin
=> true
> user.has_role? :admin
=> true
> user.roles
=> ['roles']
Roles are unique - if in doubt, add it.
A model can have as many roles as you like.
Roles can be anything you like.
TODO
- Add tests!
- Configure Redis properly (currently relies on how I like to define Redis in my Rails apps)
- Make framework agnostic
Installation
Add this line to your application's Gemfile:
gem 'rolex'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rolex
Usage
TODO: Write usage instructions here
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request