gdpr_admin 1.4.0 → 1.4.2

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: 9b1d58ff60fa19dc3b0a1fb067ae2ed0dfc96e8798257989534a39e8600ef878
4
- data.tar.gz: b199dc1a90a1fab64a6b98bcde51dc656a8943f12381dcdbc275e51147997c92
3
+ metadata.gz: 0ec941ad2e7b5708375e99e895438d87a0ba4d444793e160eb856153e50416e4
4
+ data.tar.gz: 3c32e9b55b937b8ae8f3985aa94303cdacb2886ecd310b698cc42131425ae449
5
5
  SHA512:
6
- metadata.gz: b7813fc861f53e6d280369e403e9ece16484dfc433e2005b6c6eac739f91694d06169fcf0b60a3b1d1e32f65dcc45a44a8dee5446e89a35b90391070a42c0c96
7
- data.tar.gz: 02a363b0a84f217aceeb3e19e2d0f53b09d7f5030e3dbf16abae8c92a8dc52cca9138c3fca55b6ce1014f639a915914e910c45e7538d5f24ecf79c005a3abb14
6
+ metadata.gz: 6ce2ae11b31814d2a70da810245f966247a1bff2080a6c65c44b25df4d29af81bebd04f8e0d8ae75b25f06c1a9d5e0ca40941620404dd1f8dae9f02d05a9cac0
7
+ data.tar.gz: bfee1582a3e58facf792acf4ca077cf880009d3c75129d39d6ad2203481a86805b8a2de3fd505c2246f3ebf3fd052e53e3dca4defba73657f51ebde27a0cba8a
@@ -43,14 +43,18 @@ module GdprAdmin
43
43
  def process
44
44
  GdprAdmin.config.tenant_adapter.with_tenant(request.tenant) do
45
45
  run_preprocessors
46
- scope.find_each do |record|
47
- process_record(record)
48
- end
46
+ process_scope(scope)
49
47
  rescue SkipDataPolicyError
50
48
  nil
51
49
  end
52
50
  end
53
51
 
52
+ def process_scope(scope)
53
+ scope.find_each do |record|
54
+ process_record(record)
55
+ end
56
+ end
57
+
54
58
  protected
55
59
 
56
60
  attr_reader :request
@@ -80,9 +84,13 @@ module GdprAdmin
80
84
  def call_hook(hook, value = nil)
81
85
  hook = method(hook) unless hook.respond_to?(:call)
82
86
 
83
- arity = hook.arity
87
+ arity = arity_of(hook)
84
88
  args = [value].take(arity).reverse
85
89
  instance_exec(*args, &hook)
86
90
  end
91
+
92
+ def arity_of(method_or_proc)
93
+ defined?(T::Utils.arity) ? T::Utils.arity(method_or_proc) : method_or_proc.arity
94
+ end
87
95
  end
88
96
  end
@@ -10,6 +10,16 @@ module GdprAdmin
10
10
  def skip_record!
11
11
  raise SkipRecordError
12
12
  end
13
+
14
+ def model_data_policy_class(model)
15
+ model = model.constantize if model.is_a?(String)
16
+ return model.data_policy_class if model.respond_to?(:data_policy_class)
17
+
18
+ prefix = model.data_policy_prefix if model.respond_to?(:data_policy_prefix)
19
+ "#{prefix}#{model}DataPolicy".constantize
20
+ rescue NameError
21
+ nil
22
+ end
13
23
  end
14
24
  end
15
25
  end
@@ -29,7 +29,7 @@ module GdprAdmin
29
29
  field_value = object[field_name]
30
30
  next if field_value.nil?
31
31
 
32
- new_value = anonymize_field(version.item, field)
32
+ new_value = anonymize_field_value(version.item, field.merge(seed: field_value))
33
33
  object.merge!(field_name => new_value)
34
34
  end
35
35
  object
@@ -32,13 +32,7 @@ module GdprAdmin
32
32
  end
33
33
 
34
34
  def infer_data_policy_class(version)
35
- model = version.item_type.constantize.new
36
- return model.data_policy_class if model.respond_to?(:data_policy_class)
37
-
38
- prefix = model.data_policy_prefix if model.respond_to?(:data_policy_prefix)
39
- "#{prefix}#{version.item_type}DataPolicy".constantize
40
- rescue NameError
41
- nil
35
+ model_data_policy_class(version.item_type)
42
36
  end
43
37
  end
44
38
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  # :nocov:
4
4
  module GdprAdmin
5
- VERSION = '1.4.0'
5
+ VERSION = '1.4.2'
6
6
  end
7
7
  # :nocov:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gdpr_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails