devise_roles 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 +26 -13
- data/devise_roles.gemspec +1 -0
- data/lib/devise_roles.rb +6 -4
- data/lib/devise_roles/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3588c277305ce647bfc3717d47961241d75f13
|
4
|
+
data.tar.gz: 813dc2de520bb1bbe24282daad801a3c680c34a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b18bc1fffbc9bd0827171d6b4bf9b0e1aca27924219d35ba55bc69e4383c49d33ff3449f9f2942b8f50837adc41276ae9b76f85e49085c872b5d0e69c2585b6
|
7
|
+
data.tar.gz: 0d6e5aff5357886197350e5a63441f580e6cd24cbff984c18dc846f7d2b98b94a1cbf5b180789162fb045dc83b2f7cc2832d026a623a9e666d95cda3d0ede4d5
|
data/README.md
CHANGED
@@ -22,12 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install devise_roles
|
24
24
|
|
25
|
-
Also you need to
|
26
|
-
|
27
|
-
In your **application.rb** add This
|
28
|
-
```ruby
|
29
|
-
config.autoload_paths += %W(#{config.root}/lib)
|
30
|
-
```
|
25
|
+
Also you need to require it in your Application.
|
31
26
|
You can create and initializer and add next line to it, or just write at top of your controllers
|
32
27
|
```ruby
|
33
28
|
require 'encryption/encryption'
|
@@ -84,21 +79,39 @@ Now you can go to learn methods for this *gem*.
|
|
84
79
|
|
85
80
|
Here is a list of available methods.
|
86
81
|
|
87
|
-
####
|
82
|
+
#### user_is
|
83
|
+
To check if user role is what you want use
|
84
|
+
```ruby
|
85
|
+
DeviseRoles.user_is(user_role_name, current_user)
|
86
|
+
```
|
87
|
+
Here is some example how to use it
|
88
|
+
```ruby
|
89
|
+
def some_controller_method_name
|
90
|
+
# Some other code ...
|
91
|
+
|
92
|
+
if DeviseRoles.user_is('admin', current_user)
|
93
|
+
# Everything is ok!
|
94
|
+
end
|
95
|
+
|
96
|
+
# Some other code ...
|
97
|
+
end
|
98
|
+
```
|
88
99
|
|
89
|
-
|
100
|
+
#### user_not
|
101
|
+
Also there is an opposite method
|
90
102
|
```ruby
|
91
|
-
DeviseRoles.
|
103
|
+
DeviseRoles.user_not(user_role_name, current_user)
|
92
104
|
```
|
93
105
|
Here is some example how to use it
|
94
106
|
```ruby
|
95
107
|
def some_controller_method_name
|
96
|
-
#
|
97
|
-
|
98
|
-
DeviseRoles.
|
108
|
+
# Some other code ...
|
109
|
+
|
110
|
+
if DeviseRoles.user_not('admin', current_user)
|
111
|
+
# User is NOT **admin** !!!
|
112
|
+
end
|
99
113
|
|
100
114
|
# Some other code ...
|
101
|
-
# That would be run if user is not **admin**
|
102
115
|
end
|
103
116
|
```
|
104
117
|
|
data/devise_roles.gemspec
CHANGED
data/lib/devise_roles.rb
CHANGED
@@ -2,11 +2,13 @@ require "devise_roles/version"
|
|
2
2
|
require 'rails/all'
|
3
3
|
|
4
4
|
module DeviseRoles
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
|
6
|
+
def self.user_is(user_role_name, current_user)
|
7
|
+
return current_user.role.name == user_role_name
|
9
8
|
end
|
10
9
|
|
10
|
+
def self.user_not(user_role_name, current_user)
|
11
|
+
return current_user.role.name != user_role_name
|
12
|
+
end
|
11
13
|
|
12
14
|
end
|
data/lib/devise_roles/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_roles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MarkusBansky
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.0.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.0.2
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|