Class: Etna::Clients::Magma::UpdateAttributesFromCsvWorkflowSingleModel
- Inherits:
-
UpdateAttributesFromCsvWorkflowBase
- Object
- Struct
- UpdateAttributesFromCsvWorkflowBase
- Etna::Clients::Magma::UpdateAttributesFromCsvWorkflowSingleModel
- Defined in:
- lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb
Defined Under Namespace
Classes: Row
Instance Attribute Summary
Attributes inherited from UpdateAttributesFromCsvWorkflowBase
#filepath, #hole_value, #json_values, #magma_crud, #model_name, #project_name
Instance Method Summary collapse
-
#initialize(opts) ⇒ UpdateAttributesFromCsvWorkflowSingleModel
constructor
A new instance of UpdateAttributesFromCsvWorkflowSingleModel.
- #parse_input_file ⇒ Object
Methods inherited from UpdateAttributesFromCsvWorkflowBase
#consolidate_attributes_to_hash, #each_revision, #find_attribute, #magma_client, #model_exists?, #models, #update_attributes
Constructor Details
#initialize(opts) ⇒ UpdateAttributesFromCsvWorkflowSingleModel
Returns a new instance of UpdateAttributesFromCsvWorkflowSingleModel.
201 202 203 204 205 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 201 def initialize(opts) super(**{}.update(opts)) raise "Single Model invocation must include keyword :model_name." if !opts[:model_name] raise "Invalid model #{model_name} for project #{project_name}." unless model_exists?(model_name) end |
Instance Method Details
#parse_input_file ⇒ Object
207 208 209 210 211 212 213 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 207 def parse_input_file CSV.parse(File.read(filepath), headers: true).map do |csv_row| row = Row.new(csv_row, model_name, self) yield [model_name, row.record_name, row.to_h] end end |