petergate 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/lib/petergate.rb +2 -0
- data/lib/petergate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec1bde4df29afecb38a53b0c956fe239f8889e3
|
4
|
+
data.tar.gz: a7582407ab840880df7a812f2b7d7762a3d58bd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820ba53bae0f59f4d9d09428408f6ff2c09a50bb57cef671c4cab230289567c4d8da3ec137494e2f5607c2bd98daa95c6dfaa183c01a37dfb383ddfb65d479d6
|
7
|
+
data.tar.gz: acd4474ee4e1864464a27d0587b98d1ce386464997f4d2d88090af9b3fbb036022187aea0c79d06bac99daa452c694ffc431caed5f2556e4ca5045a86ecd2132
|
data/README.md
CHANGED
@@ -6,27 +6,27 @@ Simple User Authorizations.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
gem 'petergate'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
|
13
|
+
bundle
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
|
17
|
+
gem install petergate
|
18
18
|
Make sure you already have a User model setup. Works great with [devise](https://github.com/plataformatec/devise).
|
19
19
|
|
20
20
|
Run generator to install it.
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
rails g petergate:install
|
23
|
+
rake db:migrate
|
24
24
|
|
25
25
|
This will add:
|
26
26
|
```ruby
|
27
27
|
petergate(roles: [:admin])
|
28
28
|
```
|
29
|
-
to your
|
29
|
+
to your User model.
|
30
30
|
|
31
31
|
## Usage
|
32
32
|
|
@@ -36,15 +36,15 @@ Setup permissions in your controllers the same as you would for a before filter
|
|
36
36
|
access all: [:show, :index], user: AllRest
|
37
37
|
```
|
38
38
|
|
39
|
-
Inside your views you can use
|
39
|
+
Inside your views you can use logged_in?(:admin, :customer) to show or hide content.
|
40
40
|
|
41
41
|
```erb
|
42
|
-
<%= link_to "destroy", destroy_listing_path(listing) if logged_in?(:admin) %>
|
42
|
+
<%= link_to "destroy", destroy_listing_path(listing) if logged_in?(:admin, :customer) %>
|
43
43
|
```
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
47
|
-
1. Fork it ( https://github.com/
|
47
|
+
1. Fork it ( https://github.com/isaacsloan/petergate/fork )
|
48
48
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
49
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
50
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/petergate.rb
CHANGED
@@ -29,6 +29,7 @@ module PeterGate
|
|
29
29
|
|
30
30
|
def self.included(base)
|
31
31
|
base.extend(ClassMethods)
|
32
|
+
base.helper_method :logged_in?
|
32
33
|
base.before_filter do
|
33
34
|
unless logged_in?(:admin)
|
34
35
|
message= check_access
|
@@ -67,6 +68,7 @@ module PeterGate
|
|
67
68
|
def logged_in?(*roles)
|
68
69
|
current_user && (roles & current_user.roles).any?
|
69
70
|
end
|
71
|
+
|
70
72
|
end
|
71
73
|
|
72
74
|
module UserMethods
|
data/lib/petergate/version.rb
CHANGED