bulk_dependency_eraser 1.4.1 → 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: 5258d3b15269fb6bd51a5f89f949983a3cf48862cc83f26a8f189bbc11e2ae84
4
- data.tar.gz: dbab67950500c1037266232592915a3c27f0b54102619092be465ded4a53024d
3
+ metadata.gz: 734c542b83d1cf827cadf8a8a41c30d8a86ebe7f98e539e0bdce4777f917c2e9
4
+ data.tar.gz: fedb350237abe9898c2d54077db57c1c500b76c99c6913431c2445f5fd49293a
5
5
  SHA512:
6
- metadata.gz: 351634d20e814264885ddd4746e2fbaa7a8d27c4ab78fda5d3690e21697de51d1fd51c75d2b749e6f9a4727f79e6fa43d571617364df1e44870a55aeb0e88166
7
- data.tar.gz: e8e477e1d5139bd4ac38cb3d4e4371b06688b5dc5e000d8a6a6077cc300ec998916cdd754c00d87ea1efd0b0a179479c60491450467cfc8eefbb6b0bda391690
6
+ metadata.gz: 5b69927dd186b6eac307ff85a5bd06783245c5173a6d890ff29a8abb42edbf8df105a3ed592cf3ae92f649c4547f32c289316b83ae7f02d19233a05d9a2a5d47
7
+ data.tar.gz: 9a4febdbdd779faf17bc332b8853c41bb727e722fea564ed45a8b871ee53f8e4677983c2459a4894a4304c90397a48fa927d41609e4558033ee24c43badbc4b7
@@ -37,17 +37,18 @@ module BulkDependencyEraser
37
37
 
38
38
  protected
39
39
 
40
- def custom_scope_for_klass_name(klass)
40
+ def custom_scope_for_query(query)
41
+ klass = query.klass
41
42
  if opts_c.proc_scopes_per_class_name.key?(klass.name)
42
- opts_c.proc_scopes_per_class_name[klass.name]
43
+ opts_c.proc_scopes_per_class_name[klass.name].call(query)
43
44
  else
44
45
  # See if non-class-mapped proc returns a value
45
- non_class_name_mapped_query = opts_c.proc_scopes.call(klass.where({})) # convert klass to query
46
+ non_class_name_mapped_query = opts_c.proc_scopes.call(query)
46
47
  if !non_class_name_mapped_query.nil?
47
- return opts_c.proc_scopes
48
+ return non_class_name_mapped_query
48
49
  else
49
50
  # No custom wrapper, return non-effect default
50
- return self.class::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER
51
+ return self.class::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER.call(query)
51
52
  end
52
53
  end
53
54
  end
@@ -163,11 +163,12 @@ module BulkDependencyEraser
163
163
  attr_reader :table_names_to_parsed_klass_names
164
164
  attr_reader :ignore_table_name_and_dependencies, :ignore_klass_name_and_dependencies
165
165
 
166
- def custom_scope_for_klass_name(klass)
166
+ def custom_scope_for_query(query)
167
+ klass = query.klass
167
168
  if opts_c.reading_proc_scopes_per_class_name.key?(klass.name)
168
- opts_c.reading_proc_scopes_per_class_name[klass.name]
169
+ opts_c.reading_proc_scopes_per_class_name[klass.name].call(query)
169
170
  else
170
- super(klass)
171
+ super(query)
171
172
  end
172
173
  end
173
174
 
@@ -175,7 +176,7 @@ module BulkDependencyEraser
175
176
  # ordering shouldn't matter in these queries, and would slow it down
176
177
  # - we're ignoring default_scope ordering, but assoc-defined ordering would still take effect
177
178
  query = query.reorder('')
178
- query = custom_scope_for_klass_name(query.klass).call(query)
179
+ query = custom_scope_for_query(query)
179
180
 
180
181
  query_ids = []
181
182
  read_from_db do
@@ -639,7 +640,7 @@ module BulkDependencyEraser
639
640
  return
640
641
  end
641
642
 
642
- query = custom_scope_for_klass_name(query.klass).call(query)
643
+ query = custom_scope_for_query(query)
643
644
 
644
645
  foreign_ids_by_type = read_from_db do
645
646
  if batching_disabled? || !query.where({}).limit_value.nil?
@@ -77,11 +77,12 @@ module BulkDependencyEraser
77
77
 
78
78
  attr_reader :class_names_and_ids
79
79
 
80
- def custom_scope_for_klass_name(klass)
80
+ def custom_scope_for_query(query)
81
+ klass = query.klass
81
82
  if opts_c.deletion_proc_scopes_per_class_name.key?(klass.name)
82
- opts_c.deletion_proc_scopes_per_class_name[klass.name]
83
+ opts_c.deletion_proc_scopes_per_class_name[klass.name].call(query)
83
84
  else
84
- super(klass)
85
+ super(query)
85
86
  end
86
87
  end
87
88
 
@@ -96,7 +97,7 @@ module BulkDependencyEraser
96
97
  def delete_by_klass_and_ids klass, ids
97
98
  puts "Deleting #{klass.name}'s IDs: #{ids}" if opts_c.verbose
98
99
  query = klass.unscoped
99
- query = custom_scope_for_klass_name(klass).call(query)
100
+ query = custom_scope_for_query(query)
100
101
 
101
102
  if batching_disabled?
102
103
  puts "Deleting without batching" if opts_c.verbose
@@ -135,11 +135,12 @@ module BulkDependencyEraser
135
135
 
136
136
  attr_reader :class_names_columns_and_ids
137
137
 
138
- def custom_scope_for_klass_name(klass)
138
+ def custom_scope_for_query(query)
139
+ klass = query.klass
139
140
  if opts_c.nullification_proc_scopes_per_class_name.key?(klass.name)
140
- opts_c.nullification_proc_scopes_per_class_name[klass.name]
141
+ opts_c.nullification_proc_scopes_per_class_name[klass.name].call(query)
141
142
  else
142
- super(klass)
143
+ super(query)
143
144
  end
144
145
  end
145
146
 
@@ -153,7 +154,7 @@ module BulkDependencyEraser
153
154
 
154
155
  def nullify_by_klass_column_and_ids klass, columns, ids
155
156
  query = klass.unscoped
156
- query = custom_scope_for_klass_name(klass).call(query)
157
+ query = custom_scope_for_query(query)
157
158
 
158
159
  nullify_columns = {}
159
160
  # supporting nullification of groups of columns simultaneously
@@ -1,3 +1,3 @@
1
1
  module BulkDependencyEraser
2
- VERSION = "1.4.1".freeze
2
+ VERSION = "1.4.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulk_dependency_eraser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - benjamin.dana.software.dev@gmail.com