Class: DumpCleaner::Cleanup::Cleaning
- Inherits:
-
Object
- Object
- DumpCleaner::Cleanup::Cleaning
- Includes:
- Uniqueness
- Defined in:
- lib/dump_cleaner/cleanup/cleaning.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#clean_value_for(orig_value, type:, cleanup_data:, column_config:, record: {}, keep_record: false) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#initialize(config:) ⇒ Cleaning
constructor
A new instance of Cleaning.
Methods included from Uniqueness
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/dump_cleaner/cleanup/cleaning.rb', line 8 def config @config end |
Instance Method Details
#clean_value_for(orig_value, type:, cleanup_data:, column_config:, record: {}, keep_record: false) ⇒ Object
rubocop:disable Metrics/ParameterLists
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dump_cleaner/cleanup/cleaning.rb', line 16 def clean_value_for(orig_value, type:, cleanup_data:, column_config:, record: {}, keep_record: false) # rubocop:disable Metrics/ParameterLists step_context = StepContext.new(orig_value:, type:, cleanup_data:, record:) # return orig_value if keep_same conditions are met if (keep_record && !config.ignore_keep_same_record_conditions?(type)) || Conditions.evaluate_to_true_in_step?(conditions: config.keep_same_conditions(type), step_context:) return orig_value_with_optional_suffix(step_context, column_config:) end if column_config.unique_column? begin repeat_until_unique(step_context:) do |repetition| step_context.repetition = repetition run_workflows(step_context) end rescue MaxRetriesReachedError repeat_until_unique(step_context:) do |repetition| step_context.repetition = repetition run_failure_workflow(step_context) end end else run_workflows(step_context) end end |