rabarber 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +8 -0
- data/lib/rabarber/controllers/concerns/authorization.rb +2 -2
- data/lib/rabarber/models/concerns/has_roles.rb +1 -3
- data/lib/rabarber/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: defa329a94240744ede0911a0d2724a93d5820637614d68c9d4eedd925459951
|
4
|
+
data.tar.gz: ef33ca54c1d80bc2986435eb61462e5a47c37ba7c3d04cdd33a2a8a5d2ce2d73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a16170222252d4f067686a4c129e61ff92a649504d815e11f76d74e4fb33984cf76eaa048d7b474b4dd93f89f8f816bface0456bdd9a19a6b1b17bbd12a5ae
|
7
|
+
data.tar.gz: fc89759b5cce5e8adc0dbd87aacbba28dd728a89342a72f69ff1a8366d485ec987f716febc005e8e3405d805d51d5e74523abcf830442dfbb120d4a9cb727026
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -109,6 +109,14 @@ To view all the roles assigned to the user, use:
|
|
109
109
|
```rb
|
110
110
|
user.roles
|
111
111
|
```
|
112
|
+
This will return an array of `Rabarber::Role` objects.
|
113
|
+
|
114
|
+
If you need the list of role names, use:
|
115
|
+
|
116
|
+
```rb
|
117
|
+
user.roles.names
|
118
|
+
```
|
119
|
+
|
112
120
|
If you need to list all the role names available in your application, use:
|
113
121
|
|
114
122
|
```rb
|
@@ -5,7 +5,7 @@ module Rabarber
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
before_action :
|
8
|
+
before_action :verify_access
|
9
9
|
end
|
10
10
|
|
11
11
|
class_methods do
|
@@ -16,7 +16,7 @@ module Rabarber
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def
|
19
|
+
def verify_access
|
20
20
|
return if Permissions.access_granted?(
|
21
21
|
send(::Rabarber::Configuration.instance.current_user_method).roles.names, self.class, action_name.to_sym, self
|
22
22
|
)
|
@@ -12,11 +12,9 @@ module Rabarber
|
|
12
12
|
has_and_belongs_to_many :roles, class_name: "Rabarber::Role",
|
13
13
|
foreign_key: "roleable_id",
|
14
14
|
join_table: "rabarber_roles_roleables"
|
15
|
-
|
16
|
-
alias_method :has_role?, :role?
|
17
15
|
end
|
18
16
|
|
19
|
-
def
|
17
|
+
def has_role?(*role_names)
|
20
18
|
unless role_names.all? { |arg| arg.is_a?(Symbol) || arg.is_a?(String) }
|
21
19
|
raise(ArgumentError, "Role names must be symbols or strings")
|
22
20
|
end
|
data/lib/rabarber/version.rb
CHANGED