devise_roles 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e44673da7969b00905ab5e4b1a84dcea65721f8
4
- data.tar.gz: a4a6ffcee862c92c7c5c1df1b42edb2ea21729cc
3
+ metadata.gz: d53579469d6263849aabfb1148fe6e93e2d78f37
4
+ data.tar.gz: d56a46894e63713c4c980824703250b0d2259d3d
5
5
  SHA512:
6
- metadata.gz: 165398f14b8cfa00e1edc5e27b7a396814578ccfcb17f24fa08b3b92acfcfb07d940490a8440acbece2efd5c8e22c3f7d2c4639aed834db21dcecbfa683cd21e
7
- data.tar.gz: 6e15e401122e81a0e16231eb0e7dfe0f54ca79b573c38846d71009358e3ce17082ef451adfee834c483c2cd86a6e550a590b5e24f146e028dae2fcc24588b51f
6
+ metadata.gz: c180928480d40a806290e00c5c4c599375ebce57ea269d80f4145e96175da899200e7b1eeb89bd3e8beb893b646eb7696837e88aa975f433688e2f68a7899eb7
7
+ data.tar.gz: be84e9b44328ac01c1bd766797f8096877f9b4284f50ed30ecfc17e2f9e2cef099d50c3f1cac890aca0e48139ca9ce2cf550ca5def5de567900886e0722401ba
data/README.md CHANGED
@@ -80,39 +80,27 @@ Now you can go to learn methods for this *gem*.
80
80
  Here is a list of available methods.
81
81
 
82
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
- ```
83
+ Use this to check if user has the role you need.
87
84
  Here is some example how to use it
88
85
  ```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 ...
86
+ if DeviseRoles.user_is('admin', current_user)
87
+ # Everything is ok!
97
88
  end
98
89
  ```
99
90
 
100
91
  #### user_not
101
- Also there is an opposite method
92
+ Also there is an opposite method.
93
+ Here is one more example
102
94
  ```ruby
103
- DeviseRoles.user_not(user_role_name, current_user)
95
+ if DeviseRoles.user_not('admin', current_user)
96
+ # User is NOT **admin** !!!
97
+ end
104
98
  ```
105
- Here is some example how to use it
106
- ```ruby
107
- def some_controller_method_name
108
- # Some other code ...
109
-
110
- if DeviseRoles.user_not('admin', current_user)
111
- # User is NOT **admin** !!!
112
- end
113
99
 
114
- # Some other code ...
115
- end
100
+ #### add_role_to_user
101
+ If you want quickly add specific role to user, like in the example
102
+ ```ruby
103
+ DeviseRoles.add_role_to_user(Role.where(:name => 'banned')[0], current_user)
116
104
  ```
117
105
 
118
106
  ## License
Binary file
@@ -1,3 +1,3 @@
1
1
  module DeviseRoles
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/devise_roles.rb CHANGED
@@ -11,4 +11,8 @@ module DeviseRoles
11
11
  return current_user.role.name != user_role_name
12
12
  end
13
13
 
14
+ def self.add_role_to_user(role, user)
15
+ user.role = role
16
+ end
17
+
14
18
  end
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MarkusBansky
@@ -94,6 +94,7 @@ files:
94
94
  - devise_roles-0.1.9.gem
95
95
  - devise_roles-0.2.0.gem
96
96
  - devise_roles-0.2.1.gem
97
+ - devise_roles-0.2.2.gem
97
98
  - devise_roles.gemspec
98
99
  - lib/devise_roles.rb
99
100
  - lib/devise_roles/version.rb