deidentify 2.6.1 → 3.0.0.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/deidentify.rb +26 -10
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8893f3d3da44a05d7acbb7bf3298878c4b1c304440dfc820c04a1a6de402ea0c
|
|
4
|
+
data.tar.gz: 2d3d01e976c024648a893abb4a4d1e9bd5956ab09102b76e6acbcec9e4c8d649
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 618d1a2d78f27a01692c8db10f3c80f6955200ed354bd0237b809457411899e7a6bdd9710d22fdbaecc2a17e980bc617207e8ab11aa676e3c679cbaf1c03e601
|
|
7
|
+
data.tar.gz: b1963d2866ab64d27f54966593927119aa2cd07a32343034c34b820b377fa886da7c3b56bdb3c36e7bc64fbc9dcdcf44059ece31c19ff9d32a7b807a48017b4b
|
data/lib/deidentify.rb
CHANGED
|
@@ -150,21 +150,37 @@ module Deidentify
|
|
|
150
150
|
class_query = class_query(association.scope, configuration_scope, send(association_name))
|
|
151
151
|
|
|
152
152
|
deidentify_many!(class_query)
|
|
153
|
+
elsif association.respond_to?(:polymorphic?) && association.polymorphic?
|
|
154
|
+
deidentify_polymorphic_belongs_to_with_scope!(association, configuration_scope)
|
|
153
155
|
else
|
|
154
|
-
|
|
156
|
+
deidentify_singular_with_scope!(association, configuration_scope)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
155
159
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
def deidentify_singular_with_scope!(association, configuration_scope)
|
|
161
|
+
class_query = class_query(association.scope, configuration_scope, association.klass)
|
|
162
|
+
|
|
163
|
+
if association.has_one?
|
|
164
|
+
# eg. (bubble) has_one :party, -> { birthday }
|
|
165
|
+
# This will call configuration_scope.call(Party).merge(birthday).find_by(bubble_id: id)
|
|
166
|
+
deidentify_one!(class_query.find_by("#{association.foreign_key} = #{send(:id)}"))
|
|
167
|
+
else
|
|
168
|
+
# eg. belongs_to :party, -> { birthday }
|
|
169
|
+
# This will call configuration_scope.call(Party).merge(birthday).find_by(id: party_id)
|
|
170
|
+
deidentify_one!(class_query.find_by(id: send(association.foreign_key)))
|
|
165
171
|
end
|
|
166
172
|
end
|
|
167
173
|
|
|
174
|
+
def deidentify_polymorphic_belongs_to_with_scope!(association, configuration_scope)
|
|
175
|
+
foreign_type = send(association.foreign_type)
|
|
176
|
+
foreign_key = send(association.foreign_key)
|
|
177
|
+
return if foreign_type.nil? || foreign_key.nil?
|
|
178
|
+
|
|
179
|
+
klass = foreign_type.constantize
|
|
180
|
+
class_query = class_query(association.scope, configuration_scope, klass)
|
|
181
|
+
deidentify_one!(class_query.find_by(id: foreign_key))
|
|
182
|
+
end
|
|
183
|
+
|
|
168
184
|
def class_query(association_scope, configuration_scope, klass_or_association)
|
|
169
185
|
if association_scope.nil?
|
|
170
186
|
configuration_scope.call(klass_or_association)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deidentify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0.pre.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lucy Dement
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 7.0.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:
|
|
26
|
+
version: 7.0.0
|
|
27
27
|
description: A gem to allow deidentification of certain fields
|
|
28
28
|
email:
|
|
29
29
|
executables: []
|
|
@@ -54,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
54
54
|
requirements:
|
|
55
55
|
- - ">="
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: '2
|
|
57
|
+
version: '3.2'
|
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
60
|
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
62
|
version: '0'
|
|
63
63
|
requirements: []
|
|
64
|
-
rubygems_version: 3.
|
|
64
|
+
rubygems_version: 3.5.22
|
|
65
65
|
signing_key:
|
|
66
66
|
specification_version: 4
|
|
67
67
|
summary: Deidentify a rails model
|