Class: DumpCleaner::Cleanup::DataSourceSteps::LoadYamlFile

Inherits:
Base
  • Object
show all
Defined in:
lib/dump_cleaner/cleanup/data_source_steps/load_yaml_file.rb

Instance Attribute Summary

Attributes inherited from Base

#step_context

Instance Method Summary collapse

Methods inherited from Base

#initialize, #raise_params_error

Constructor Details

This class inherits a constructor from DumpCleaner::Cleanup::DataSourceSteps::Base

Instance Method Details

#run(file:, under_key: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dump_cleaner/cleanup/data_source_steps/load_yaml_file.rb', line 9

def run(file:, under_key: nil)
  loaded_data = YAML.load_file(file)

  step_context.cleanup_data = if under_key
                                new_data ||= cleanup_data || {}
                                new_data[under_key] = loaded_data
                                new_data
                              else
                                loaded_data
                              end
  step_context
end