rolify 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,28 +1,17 @@
1
1
  = rolify
2
2
 
3
- Very simple Roles library without any authorization enforcement (built to use with cancan) supporting scope on object.
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) => # return false if user is moderator of another Forum
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 Modle
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
- # => true
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
- # => true
70
+ => true
82
71
  user.has_role "moderator", Forum.last
83
- # => false
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
- * Write specs
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
@@ -1,3 +1,4 @@
1
1
  class <%= role_cname.camelize %> < ActiveRecord::Base
2
2
  has_and_belongs_to_many :<%= user_cname.tableize %>
3
+ belongs_to :resource, :polymorphic => true
3
4
  end
@@ -1,3 +1,3 @@
1
1
  module Rolify
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rolify
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Florent Monbillard