active_admin_role 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +16 -13
- data/.rubocop_todo.yml +23 -0
- data/.travis.yml +12 -3
- data/Appraisals +8 -9
- data/Gemfile +13 -10
- data/README.md +8 -4
- data/Rakefile +32 -3
- data/active_admin_role.gemspec +4 -3
- data/app/models/active_admin/manageable_resource.rb +51 -0
- data/app/models/active_admin/managed_resource.rb +5 -42
- data/app/models/active_admin/permission.rb +12 -17
- data/app/models/active_admin/permission_reloader.rb +47 -0
- data/app/models/active_admin_role/can_can/ability.rb +17 -0
- data/app/models/active_admin_role/dsl.rb +7 -0
- data/app/models/active_admin_role/role_based_authorizable.rb +43 -0
- data/gemfiles/{rails42.gemfile → 5.0.gemfile} +11 -11
- data/gemfiles/5.1.gemfile +26 -0
- data/gemfiles/5.2.gemfile +26 -0
- data/lib/active_admin_role.rb +3 -10
- data/lib/active_admin_role/active_admin/dsl.rb +1 -2
- data/lib/active_admin_role/active_admin/resource_controller.rb +11 -11
- data/lib/active_admin_role/config.rb +3 -2
- data/lib/active_admin_role/engine.rb +5 -2
- data/lib/active_admin_role/version.rb +1 -1
- data/lib/generators/active_admin_role/helper.rb +41 -41
- data/lib/generators/active_admin_role/install_generator.rb +16 -13
- data/lib/generators/active_admin_role/templates/admin/{permission.rb → permissions.tt} +1 -1
- data/lib/generators/active_admin_role/templates/{initializer.rb → initializer.tt} +0 -0
- data/lib/generators/active_admin_role/templates/migration/{add_role_to_admin_users.rb → add_role_to_admin_users.tt} +0 -0
- data/lib/generators/active_admin_role/templates/migration/{create_active_admin_managed_resources.rb → create_active_admin_managed_resources.tt} +0 -0
- data/lib/generators/active_admin_role/templates/migration/{create_active_admin_permissions.rb → create_active_admin_permissions.tt} +0 -0
- data/lib/generators/active_admin_role/templates/model/{ability.rb → ability.tt} +0 -0
- metadata +35 -21
- data/.ruby-style.yml +0 -242
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/rails50.gemfile +0 -27
- data/lib/active_admin_role/can_can/ability.rb +0 -15
- data/lib/active_admin_role/manageable_resource.rb +0 -45
- data/lib/active_admin_role/model.rb +0 -7
- data/lib/active_admin_role/role_based_authorizable.rb +0 -45
- data/tasks/test.rake +0 -10
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cancancan
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.15.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 5.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 5.0.0
|
41
55
|
description: Role based authorization with CanCanCan for Active Admin
|
42
56
|
email:
|
43
57
|
- yhirano@me.com
|
@@ -48,7 +62,7 @@ files:
|
|
48
62
|
- ".gitignore"
|
49
63
|
- ".rspec"
|
50
64
|
- ".rubocop.yml"
|
51
|
-
- ".
|
65
|
+
- ".rubocop_todo.yml"
|
52
66
|
- ".travis.yml"
|
53
67
|
- Appraisals
|
54
68
|
- Gemfile
|
@@ -56,33 +70,33 @@ files:
|
|
56
70
|
- README.md
|
57
71
|
- Rakefile
|
58
72
|
- active_admin_role.gemspec
|
73
|
+
- app/models/active_admin/manageable_resource.rb
|
59
74
|
- app/models/active_admin/managed_resource.rb
|
60
75
|
- app/models/active_admin/permission.rb
|
76
|
+
- app/models/active_admin/permission_reloader.rb
|
77
|
+
- app/models/active_admin_role/can_can/ability.rb
|
78
|
+
- app/models/active_admin_role/dsl.rb
|
79
|
+
- app/models/active_admin_role/role_based_authorizable.rb
|
61
80
|
- config/locales/en.yml
|
62
81
|
- config/locales/ja.yml
|
63
|
-
- gemfiles
|
64
|
-
- gemfiles/
|
65
|
-
- gemfiles/
|
82
|
+
- gemfiles/5.0.gemfile
|
83
|
+
- gemfiles/5.1.gemfile
|
84
|
+
- gemfiles/5.2.gemfile
|
66
85
|
- lib/active_admin_role.rb
|
67
86
|
- lib/active_admin_role/active_admin/dsl.rb
|
68
87
|
- lib/active_admin_role/active_admin/resource_controller.rb
|
69
|
-
- lib/active_admin_role/can_can/ability.rb
|
70
88
|
- lib/active_admin_role/config.rb
|
71
89
|
- lib/active_admin_role/engine.rb
|
72
|
-
- lib/active_admin_role/manageable_resource.rb
|
73
|
-
- lib/active_admin_role/model.rb
|
74
|
-
- lib/active_admin_role/role_based_authorizable.rb
|
75
90
|
- lib/active_admin_role/version.rb
|
76
91
|
- lib/generators/active_admin_role/USAGE
|
77
92
|
- lib/generators/active_admin_role/helper.rb
|
78
93
|
- lib/generators/active_admin_role/install_generator.rb
|
79
|
-
- lib/generators/active_admin_role/templates/admin/
|
80
|
-
- lib/generators/active_admin_role/templates/initializer.
|
81
|
-
- lib/generators/active_admin_role/templates/migration/add_role_to_admin_users.
|
82
|
-
- lib/generators/active_admin_role/templates/migration/create_active_admin_managed_resources.
|
83
|
-
- lib/generators/active_admin_role/templates/migration/create_active_admin_permissions.
|
84
|
-
- lib/generators/active_admin_role/templates/model/ability.
|
85
|
-
- tasks/test.rake
|
94
|
+
- lib/generators/active_admin_role/templates/admin/permissions.tt
|
95
|
+
- lib/generators/active_admin_role/templates/initializer.tt
|
96
|
+
- lib/generators/active_admin_role/templates/migration/add_role_to_admin_users.tt
|
97
|
+
- lib/generators/active_admin_role/templates/migration/create_active_admin_managed_resources.tt
|
98
|
+
- lib/generators/active_admin_role/templates/migration/create_active_admin_permissions.tt
|
99
|
+
- lib/generators/active_admin_role/templates/model/ability.tt
|
86
100
|
homepage: https://github.com/yhirano55/active_admin_role
|
87
101
|
licenses:
|
88
102
|
- MIT
|
@@ -95,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
109
|
requirements:
|
96
110
|
- - ">="
|
97
111
|
- !ruby/object:Gem::Version
|
98
|
-
version: 2.
|
112
|
+
version: 2.2.2
|
99
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
@@ -103,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
117
|
version: '0'
|
104
118
|
requirements: []
|
105
119
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.6
|
120
|
+
rubygems_version: 2.7.6
|
107
121
|
signing_key:
|
108
122
|
specification_version: 4
|
109
123
|
summary: Role based authorization with CanCanCan for Active Admin
|
data/.ruby-style.yml
DELETED
@@ -1,242 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- "vendor/**/*"
|
4
|
-
UseCache: false
|
5
|
-
Style/CollectionMethods:
|
6
|
-
Description: Preferred collection methods.
|
7
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
8
|
-
Enabled: true
|
9
|
-
PreferredMethods:
|
10
|
-
collect: map
|
11
|
-
collect!: map!
|
12
|
-
find: detect
|
13
|
-
find_all: select
|
14
|
-
reduce: inject
|
15
|
-
Style/DotPosition:
|
16
|
-
Description: Checks the position of the dot in multi-line method calls.
|
17
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
18
|
-
Enabled: true
|
19
|
-
EnforcedStyle: trailing
|
20
|
-
SupportedStyles:
|
21
|
-
- leading
|
22
|
-
- trailing
|
23
|
-
Style/FileName:
|
24
|
-
Description: Use snake_case for source file names.
|
25
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
26
|
-
Enabled: false
|
27
|
-
Exclude: []
|
28
|
-
Style/GuardClause:
|
29
|
-
Description: Check for conditionals that can be replaced with guard clauses
|
30
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
31
|
-
Enabled: false
|
32
|
-
MinBodyLength: 1
|
33
|
-
Style/IfUnlessModifier:
|
34
|
-
Description: Favor modifier if/unless usage when you have a single-line body.
|
35
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
36
|
-
Enabled: false
|
37
|
-
MaxLineLength: 80
|
38
|
-
Style/OptionHash:
|
39
|
-
Description: Don't use option hashes when you can use keyword arguments.
|
40
|
-
Enabled: false
|
41
|
-
Style/PercentLiteralDelimiters:
|
42
|
-
Description: Use `%`-literal delimiters consistently
|
43
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
44
|
-
Enabled: false
|
45
|
-
PreferredDelimiters:
|
46
|
-
"%": "()"
|
47
|
-
"%i": "()"
|
48
|
-
"%q": "()"
|
49
|
-
"%Q": "()"
|
50
|
-
"%r": "{}"
|
51
|
-
"%s": "()"
|
52
|
-
"%w": "()"
|
53
|
-
"%W": "()"
|
54
|
-
"%x": "()"
|
55
|
-
Style/PredicateName:
|
56
|
-
Description: Check the names of predicate methods.
|
57
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
58
|
-
Enabled: true
|
59
|
-
NamePrefix:
|
60
|
-
- is_
|
61
|
-
- has_
|
62
|
-
- have_
|
63
|
-
NamePrefixBlacklist:
|
64
|
-
- is_
|
65
|
-
Exclude:
|
66
|
-
- spec/**/*
|
67
|
-
Style/RaiseArgs:
|
68
|
-
Description: Checks the arguments passed to raise/fail.
|
69
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
70
|
-
Enabled: false
|
71
|
-
EnforcedStyle: exploded
|
72
|
-
SupportedStyles:
|
73
|
-
- compact
|
74
|
-
- exploded
|
75
|
-
Style/SignalException:
|
76
|
-
Description: Checks for proper usage of fail and raise.
|
77
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
78
|
-
Enabled: false
|
79
|
-
EnforcedStyle: semantic
|
80
|
-
SupportedStyles:
|
81
|
-
- only_raise
|
82
|
-
- only_fail
|
83
|
-
- semantic
|
84
|
-
Style/SingleLineBlockParams:
|
85
|
-
Description: Enforces the names of some block params.
|
86
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
87
|
-
Enabled: false
|
88
|
-
Methods:
|
89
|
-
- reduce:
|
90
|
-
- a
|
91
|
-
- e
|
92
|
-
- inject:
|
93
|
-
- a
|
94
|
-
- e
|
95
|
-
Style/SingleLineMethods:
|
96
|
-
Description: Avoid single-line methods.
|
97
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
98
|
-
Enabled: false
|
99
|
-
AllowIfMethodIsEmpty: true
|
100
|
-
Style/StringLiterals:
|
101
|
-
Description: Checks if uses of quotes match the configured preference.
|
102
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
103
|
-
Enabled: true
|
104
|
-
EnforcedStyle: double_quotes
|
105
|
-
SupportedStyles:
|
106
|
-
- single_quotes
|
107
|
-
- double_quotes
|
108
|
-
Style/StringLiteralsInInterpolation:
|
109
|
-
Description: Checks if uses of quotes inside expressions in interpolated strings
|
110
|
-
match the configured preference.
|
111
|
-
Enabled: true
|
112
|
-
EnforcedStyle: single_quotes
|
113
|
-
SupportedStyles:
|
114
|
-
- single_quotes
|
115
|
-
- double_quotes
|
116
|
-
Style/TrailingCommaInArguments:
|
117
|
-
Description: 'Checks for trailing comma in argument lists.'
|
118
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
119
|
-
Enabled: false
|
120
|
-
EnforcedStyleForMultiline: no_comma
|
121
|
-
SupportedStyles:
|
122
|
-
- comma
|
123
|
-
- consistent_comma
|
124
|
-
- no_comma
|
125
|
-
Style/TrailingCommaInLiteral:
|
126
|
-
Description: 'Checks for trailing comma in array and hash literals.'
|
127
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
128
|
-
Enabled: false
|
129
|
-
EnforcedStyleForMultiline: no_comma
|
130
|
-
SupportedStyles:
|
131
|
-
- comma
|
132
|
-
- consistent_comma
|
133
|
-
- no_comma
|
134
|
-
Metrics/AbcSize:
|
135
|
-
Description: A calculated magnitude based on number of assignments, branches, and
|
136
|
-
conditions.
|
137
|
-
Enabled: false
|
138
|
-
Max: 15
|
139
|
-
Metrics/ClassLength:
|
140
|
-
Description: Avoid classes longer than 100 lines of code.
|
141
|
-
Enabled: false
|
142
|
-
CountComments: false
|
143
|
-
Max: 100
|
144
|
-
Metrics/ModuleLength:
|
145
|
-
CountComments: false
|
146
|
-
Max: 100
|
147
|
-
Description: Avoid modules longer than 100 lines of code.
|
148
|
-
Enabled: false
|
149
|
-
Metrics/CyclomaticComplexity:
|
150
|
-
Description: A complexity metric that is strongly correlated to the number of test
|
151
|
-
cases needed to validate a method.
|
152
|
-
Enabled: false
|
153
|
-
Max: 6
|
154
|
-
Metrics/MethodLength:
|
155
|
-
Description: Avoid methods longer than 10 lines of code.
|
156
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
157
|
-
Enabled: false
|
158
|
-
CountComments: false
|
159
|
-
Max: 10
|
160
|
-
Metrics/ParameterLists:
|
161
|
-
Description: Avoid parameter lists longer than three or four parameters.
|
162
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
163
|
-
Enabled: false
|
164
|
-
Max: 5
|
165
|
-
CountKeywordArgs: true
|
166
|
-
Metrics/PerceivedComplexity:
|
167
|
-
Description: A complexity metric geared towards measuring complexity for a human
|
168
|
-
reader.
|
169
|
-
Enabled: false
|
170
|
-
Max: 7
|
171
|
-
Lint/AssignmentInCondition:
|
172
|
-
Description: Don't use assignment in conditions.
|
173
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
174
|
-
Enabled: false
|
175
|
-
AllowSafeAssignment: true
|
176
|
-
Style/InlineComment:
|
177
|
-
Description: Avoid inline comments.
|
178
|
-
Enabled: false
|
179
|
-
Style/AccessorMethodName:
|
180
|
-
Description: Check the naming of accessor methods for get_/set_.
|
181
|
-
Enabled: false
|
182
|
-
Style/Alias:
|
183
|
-
Description: Use alias_method instead of alias.
|
184
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
185
|
-
Enabled: false
|
186
|
-
Style/Documentation:
|
187
|
-
Description: Document classes and non-namespace modules.
|
188
|
-
Enabled: false
|
189
|
-
Style/DoubleNegation:
|
190
|
-
Description: Checks for uses of double negation (!!).
|
191
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
192
|
-
Enabled: false
|
193
|
-
Style/EachWithObject:
|
194
|
-
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
195
|
-
Enabled: false
|
196
|
-
Style/EmptyLiteral:
|
197
|
-
Description: Prefer literals to Array.new/Hash.new/String.new.
|
198
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
199
|
-
Enabled: false
|
200
|
-
Style/ModuleFunction:
|
201
|
-
Description: Checks for usage of `extend self` in modules.
|
202
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
203
|
-
Enabled: false
|
204
|
-
Style/OneLineConditional:
|
205
|
-
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
206
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
207
|
-
Enabled: false
|
208
|
-
Style/PerlBackrefs:
|
209
|
-
Description: Avoid Perl-style regex back references.
|
210
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
211
|
-
Enabled: false
|
212
|
-
Style/Send:
|
213
|
-
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
214
|
-
may overlap with existing methods.
|
215
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
216
|
-
Enabled: false
|
217
|
-
Style/SpecialGlobalVars:
|
218
|
-
Description: Avoid Perl-style global variables.
|
219
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
220
|
-
Enabled: false
|
221
|
-
Style/VariableInterpolation:
|
222
|
-
Description: Don't interpolate global, instance and class variables directly in
|
223
|
-
strings.
|
224
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
225
|
-
Enabled: false
|
226
|
-
Style/WhenThen:
|
227
|
-
Description: Use when x then ... for one-line cases.
|
228
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
229
|
-
Enabled: false
|
230
|
-
Lint/EachWithObjectArgument:
|
231
|
-
Description: Check for immutable argument given to each_with_object.
|
232
|
-
Enabled: true
|
233
|
-
Lint/HandleExceptions:
|
234
|
-
Description: Don't suppress exception.
|
235
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
236
|
-
Enabled: false
|
237
|
-
Lint/LiteralInCondition:
|
238
|
-
Description: Checks of literals used in conditions.
|
239
|
-
Enabled: false
|
240
|
-
Lint/LiteralInInterpolation:
|
241
|
-
Description: Checks for literals used in interpolation.
|
242
|
-
Enabled: false
|
data/gemfiles/.bundle/config
DELETED
data/gemfiles/rails50.gemfile
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 5.0.0"
|
6
|
-
gem "activeadmin", :github => "activeadmin/activeadmin"
|
7
|
-
gem "devise", "~> 4.2.0"
|
8
|
-
gem "pry"
|
9
|
-
gem "appraisal"
|
10
|
-
gem "inherited_resources", :github => "activeadmin/inherited_resources"
|
11
|
-
|
12
|
-
group :development do
|
13
|
-
gem "bundler", "~> 1.13.0"
|
14
|
-
gem "rake", "~> 10.0"
|
15
|
-
gem "rubocop", "~> 0.40.0"
|
16
|
-
end
|
17
|
-
|
18
|
-
group :test do
|
19
|
-
gem "capybara"
|
20
|
-
gem "rspec-rails"
|
21
|
-
gem "database_cleaner"
|
22
|
-
gem "shoulda-matchers"
|
23
|
-
gem "sqlite3", :platforms => :mri
|
24
|
-
gem "poltergeist"
|
25
|
-
end
|
26
|
-
|
27
|
-
gemspec :path => "../"
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module ActiveAdminRole
|
2
|
-
module CanCan
|
3
|
-
module Ability
|
4
|
-
private
|
5
|
-
|
6
|
-
def register_role_based_abilities(user)
|
7
|
-
return if user.guest_user?
|
8
|
-
|
9
|
-
(::ActiveAdmin::Permission.indexed_cache[user.role] || []).select(&:active?).each do |permission|
|
10
|
-
send(*permission.to_condition)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require "set"
|
2
|
-
|
3
|
-
module ActiveAdminRole
|
4
|
-
class ManageableResource
|
5
|
-
def call
|
6
|
-
namespace = ::ActiveAdmin.application.default_namespace
|
7
|
-
::ActiveAdmin.application.namespaces[namespace].resources.inject([]) do |result, resource|
|
8
|
-
class_name = resource.controller.resource_class.to_s
|
9
|
-
name = resource.resource_name.name
|
10
|
-
actions = collect_defined_actions(resource)
|
11
|
-
|
12
|
-
result += eval_actions(actions).map do |action|
|
13
|
-
{ class_name: class_name, name: name, action: action }
|
14
|
-
end
|
15
|
-
|
16
|
-
result
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def collect_defined_actions(resource)
|
23
|
-
if resource.respond_to?(:defined_actions)
|
24
|
-
defined_actions = resource.defined_actions
|
25
|
-
member_actions = resource.member_actions.map(&:name)
|
26
|
-
collection_actions = resource.collection_actions.map(&:name)
|
27
|
-
batch_actions = resource.batch_actions_enabled? ? [:batch_action] : []
|
28
|
-
|
29
|
-
defined_actions | member_actions | member_actions | collection_actions | batch_actions
|
30
|
-
else
|
31
|
-
resource.page_actions.map(&:name) | [:index]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def eval_actions(actions)
|
36
|
-
actions.inject(Set.new) do |result, action|
|
37
|
-
result << (actions_dictionary[action] || action).to_s
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def actions_dictionary
|
42
|
-
@_actions_dictionary ||= ::ActiveAdmin::BaseController::Authorization::ACTIONS_DICTIONARY.dup
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|