active_admin_basic_authorization_adapter 0.0.31 → 0.0.33

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
  SHA256:
3
- metadata.gz: ead1a66bd640d3fd53a109487bad15c3bfea98825ea44d43240608e238d18886
4
- data.tar.gz: b0fe2cc328b4e1eb8c2949413282205e3237be73c1a7aef3c972f11b2feb9402
3
+ metadata.gz: 27f834eec05025b47239d305055cb23d4f0404346737d3afeb604d39eb838f8f
4
+ data.tar.gz: a63c7b485acc15077b6f6e5aea3eb942f7019e82fd2b275de8fe8bd101afc37a
5
5
  SHA512:
6
- metadata.gz: 158892e8e3b17ff2da3562085ef7d1ef2c1ac7f2d0a94ca4c381072aa3b8554104976ddecc2ac2236584b05f9abae8a358372d200e5be29b6c5e82b801d33468
7
- data.tar.gz: e5ab805c1fc2ad86a9a3e3e9eecbe5a497305aba64d5a20d946461cef7ec1c4a7b8d16719fb686f950fb341c1ed771adacc5c836523231c8590a737962d6045d
6
+ metadata.gz: ff03bebb8e7505c6886c2c33a1bb64839162b047de6357ada635bcab16260fb47864859c11c07f01e962c26cae55b8b9bc99b4feb0593882dccd61b4a17e59b4
7
+ data.tar.gz: d81f7e10e75cc6be485c68096db7a7d1c14959694afb0df2d0067c936c7e686e42939ec2599a4bf7cefa769448e91d8513de08387cd8485d50d6bf97ce3be094
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAdmin
4
+ module Authorizations
5
+ class DefaultAuthorization
6
+ def initialize(user, record = nil)
7
+ @user = user
8
+ @record = record
9
+ end
10
+
11
+ def read
12
+ true
13
+ end
14
+
15
+ def create
16
+ true
17
+ end
18
+
19
+ def update
20
+ true
21
+ end
22
+
23
+ def destroy
24
+ true
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # require 'active_admin'
4
- # require 'active_admin/page'
5
3
  require 'active_admin/authorization_adapter'
6
4
 
7
5
  class ActiveAdminBasicAuthorizationAdapter < ActiveAdmin::AuthorizationAdapter
@@ -11,7 +9,7 @@ class ActiveAdminBasicAuthorizationAdapter < ActiveAdmin::AuthorizationAdapter
11
9
  set_record(subject)
12
10
  set_authorization_class(subject)
13
11
  @authorization_class.new(user, @record).send(action)
14
- rescue StandardError
12
+ rescue NameError
15
13
  begin
16
14
  ActiveAdmin::Authorizations::DefaultAuthorization.new(user, @record).send(action)
17
15
  rescue StandardError
@@ -3,7 +3,7 @@ Generates admin authorizations file with default crud to false.
3
3
  Customize methods to change the authorizations
4
4
 
5
5
  Example:
6
- bin/rails generate basic_admin_authorization Thing
6
+ bin/rails generate basic_admin_authorization:authorization Thing
7
7
 
8
8
  This will create:
9
9
  app/admin/authorizations/thing_authorization.rb
@@ -11,7 +11,7 @@ bin/rails generate basic_admin_authorization Thing
11
11
  You can also pass an option admin_type that will the default code in all the basic CRUD methods
12
12
 
13
13
  Example:
14
- bin/rails generate basic_admin_authorization Thing --admin_type 'true'
14
+ bin/rails generate basic_admin_authorization:authorization Thing --admin_type 'true'
15
15
 
16
16
  This will create:
17
17
  app/admin/authorizations/thing_authorization.rb
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BasicAdminAuthorization
4
+ module Generators
5
+ class AuthorizationGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('templates', __dir__)
7
+ class_option :admin_type, type: :string, desc: 'Admin type', default: 'false'
8
+
9
+ def create_authorizations_file
10
+ authorization = options[:admin_type]
11
+
12
+ create_file "app/admin/authorizations/#{file_name}_authorization.rb", <<~FILE
13
+ # frozen_string_literal: true
14
+
15
+ module ActiveAdmin
16
+ module Authorizations
17
+ class #{class_name}Authorization < DefaultAuthorization
18
+ def read
19
+ #{authorization}
20
+ end
21
+
22
+ def create
23
+ #{authorization}
24
+ end
25
+
26
+ def update
27
+ #{authorization}
28
+ end
29
+
30
+ def destroy
31
+ #{authorization}
32
+ end
33
+
34
+ # Add your custom member_actions here
35
+ end
36
+ end
37
+ end
38
+ FILE
39
+ end
40
+ end
41
+ end
42
+ end
@@ -2,7 +2,7 @@ Description:
2
2
  Generates default admin authorization file with default crud to false.
3
3
 
4
4
  Example:
5
- bin/rails generate default_basic_admin_authorization
5
+ bin/rails generate basic_admin_authorization:default_authorization
6
6
 
7
7
  This will create:
8
8
  app/admin/authorizations/default_authorization.rb
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BasicAdminAuthorization
4
+ module Generators
5
+ class DefaultAuthorizationGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def create_authorizations_file
9
+ create_file 'app/admin/authorizations/default_authorization.rb', <<~FILE
10
+ # frozen_string_literal: true
11
+
12
+ module ActiveAdmin
13
+ module Authorizations
14
+ class DefaultAuthorization
15
+ def initialize(user, record = nil)
16
+ @user = user
17
+ @record = record
18
+ end
19
+
20
+ def read
21
+ false
22
+ end
23
+
24
+ def create
25
+ false
26
+ end
27
+
28
+ def update
29
+ false
30
+ end
31
+
32
+ def destroy
33
+ false
34
+ end
35
+ end
36
+ end
37
+ end
38
+ FILE
39
+ end
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_basic_authorization_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Wallaere
@@ -117,11 +117,12 @@ executables: []
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
+ - lib/active_admin/authorizations/default_authorization.rb
120
121
  - lib/active_admin_basic_authorization_adapter.rb
121
- - lib/generators/admin_authorization/USAGE
122
- - lib/generators/admin_authorization/basic_admin_authorization_generator.rb
123
- - lib/generators/default_admin_authorization/USAGE
124
- - lib/generators/default_admin_authorization/default_basic_admin_authorization_generator.rb
122
+ - lib/generators/basic_admin_authorization/authorization/USAGE
123
+ - lib/generators/basic_admin_authorization/authorization/authorization_generator.rb
124
+ - lib/generators/basic_admin_authorization/default_authorization/USAGE
125
+ - lib/generators/basic_admin_authorization/default_authorization/default_authorization_generator.rb
125
126
  homepage: https://rubygems.org/gems/active_admin_basic_authorization_adapter
126
127
  licenses:
127
128
  - MIT
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class BasicAdminAuthorizationGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path('templates', __dir__)
5
- class_option :admin_type, type: :string, desc: 'Admin type', default: 'false'
6
-
7
- def create_authorizations_file
8
- authorization = options[:admin_type]
9
-
10
- create_file "app/admin/authorizations/#{file_name}_authorization.rb", <<~FILE
11
- # frozen_string_literal: true
12
-
13
- module ActiveAdmin
14
- module Authorizations
15
- class #{class_name}Authorization < DefaultAuthorization
16
- def read
17
- #{authorization}
18
- end
19
-
20
- def create
21
- #{authorization}
22
- end
23
-
24
- def update
25
- #{authorization}
26
- end
27
-
28
- def destroy
29
- #{authorization}
30
- end
31
-
32
- # Add your custom member_actions here
33
- end
34
- end
35
- end
36
- FILE
37
- end
38
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class DefaultBasicAdminAuthorizationGenerator < Rails::Generators::Base
4
- source_root File.expand_path('templates', __dir__)
5
-
6
- def create_authorizations_file
7
- create_file 'app/admin/authorizations/default_authorization.rb', <<~FILE
8
- # frozen_string_literal: true
9
-
10
- module ActiveAdmin
11
- module Authorizations
12
- class DefaultAuthorization
13
- def initialize(user, record = nil)
14
- @user = user
15
- @record = record
16
- end
17
-
18
- def read
19
- false
20
- end
21
-
22
- def create
23
- false
24
- end
25
-
26
- def update
27
- false
28
- end
29
-
30
- def destroy
31
- false
32
- end
33
- end
34
- end
35
- end
36
- FILE
37
- end
38
- end