Class: BulkDependencyEraser::Manager
- Inherits:
-
Base
- Object
- Base
- BulkDependencyEraser::Manager
show all
- Defined in:
- lib/bulk_dependency_eraser/manager.rb
Constant Summary
collapse
- DEFAULT_OPTS =
{
verbose: false,
}.freeze
Constants inherited
from Base
Base::DEFAULT_DB_BLANK_WRAPPER, Base::DEFAULT_DB_READ_WRAPPER, Base::DEFAULT_DB_WRITE_WRAPPER, Base::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER, Base::DEFAULT_SCOPE_WRAPPER, Base::DEPENDENCY_DESTROY, Base::DEPENDENCY_DESTROY_IGNORE_REFLECTION_TYPES, Base::DEPENDENCY_NULLIFY, Base::DEPENDENCY_RESTRICT, Base::POLY_KLASS_NAME
Instance Attribute Summary
Attributes inherited from Base
#errors
Instance Method Summary
collapse
Methods inherited from Base
#merge_errors, #report_error
#deep_freeze
Constructor Details
#initialize(query:, opts: {}) ⇒ Manager
Returns a new instance of Manager.
15
16
17
18
19
20
21
22
23
|
# File 'lib/bulk_dependency_eraser/manager.rb', line 15
def initialize query:, opts: {}
@opts = opts
@dependency_builder = BulkDependencyEraser::Builder.new(query:, opts:)
@deleter = nil
@nullifier = nil
@built = false
super(opts:)
end
|
Instance Method Details
#build ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/bulk_dependency_eraser/manager.rb', line 36
def build
builder_execution = @dependency_builder.execute
unless builder_execution
puts "Builder execution FAILED" if opts_c.verbose
merge_errors(dependency_builder.errors, 'Builder: ')
else
puts "Builder execution SUCCESSFUL" if opts_c.verbose
end
@built = true
return builder_execution
end
|
#delete! ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/bulk_dependency_eraser/manager.rb', line 51
def delete!
@deleter = BulkDependencyEraser::Deleter.new(class_names_and_ids: deletion_list, opts:)
deleter_execution = deleter.execute
unless deleter_execution
puts "Deleter execution FAILED" if opts_c.verbose
merge_errors(deleter.errors, 'Deleter: ')
else
puts "Deleter execution SUCCESSFUL" if opts_c.verbose
end
return deleter_execution
end
|
#execute ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/bulk_dependency_eraser/manager.rb', line 25
def execute
unless built
return false unless build
end
nullify! && delete!
return errors.none?
end
|
#nullify! ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/bulk_dependency_eraser/manager.rb', line 64
def nullify!
@nullifier = BulkDependencyEraser::Nullifier.new(class_names_columns_and_ids: nullification_list, opts:)
nullifier_execution = nullifier.execute
unless nullifier_execution
puts "Nullifier execution FAILED" if opts_c.verbose
merge_errors(nullifier.errors, 'Nullifier: ')
else
puts "Nullifier execution SUCCESSFUL" if opts_c.verbose
end
return nullifier_execution
end
|