Class: Etna::Clients::Magma::UpdateAttributesFromCsvWorkflowBase
- Inherits:
-
Struct
- Object
- Struct
- Etna::Clients::Magma::UpdateAttributesFromCsvWorkflowBase
- Defined in:
- lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb
Direct Known Subclasses
UpdateAttributesFromCsvWorkflowMultiModel, UpdateAttributesFromCsvWorkflowSingleModel
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#hole_value ⇒ Object
Returns the value of attribute hole_value.
-
#json_values ⇒ Object
Returns the value of attribute json_values.
-
#magma_crud ⇒ Object
Returns the value of attribute magma_crud.
-
#model_name ⇒ Object
Returns the value of attribute model_name.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
Instance Method Summary collapse
- #consolidate_attributes_to_hash(row) ⇒ Object
- #each_revision ⇒ Object
- #find_attribute(model_name, attribute_name) ⇒ Object
-
#initialize(opts) ⇒ UpdateAttributesFromCsvWorkflowBase
constructor
A new instance of UpdateAttributesFromCsvWorkflowBase.
- #magma_client ⇒ Object
- #model_exists?(model_name) ⇒ Boolean
- #models ⇒ Object
- #parse_input_file ⇒ Object
- #update_attributes ⇒ Object
Constructor Details
#initialize(opts) ⇒ UpdateAttributesFromCsvWorkflowBase
Returns a new instance of UpdateAttributesFromCsvWorkflowBase.
9 10 11 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 9 def initialize(opts) super(**{}.update(opts)) end |
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath
8 9 10 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 8 def filepath @filepath end |
#hole_value ⇒ Object
Returns the value of attribute hole_value
8 9 10 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 8 def hole_value @hole_value end |
#json_values ⇒ Object
Returns the value of attribute json_values
8 9 10 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 8 def json_values @json_values end |
#magma_crud ⇒ Object
Returns the value of attribute magma_crud
8 9 10 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 8 def magma_crud @magma_crud end |
#model_name ⇒ Object
Returns the value of attribute model_name
8 9 10 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 8 def model_name @model_name end |
#project_name ⇒ Object
Returns the value of attribute project_name
8 9 10 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 8 def project_name @project_name end |
Instance Method Details
#consolidate_attributes_to_hash(row) ⇒ Object
25 26 27 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 25 def consolidate_attributes_to_hash(row) raise "Must be implemented in a subclass" end |
#each_revision ⇒ Object
33 34 35 36 37 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 33 def each_revision parse_input_file do |model_name, record_name, revision| yield [model_name, record_name, revision] end end |
#find_attribute(model_name, attribute_name) ⇒ Object
29 30 31 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 29 def find_attribute(model_name, attribute_name) models.model(model_name).template.attributes.attribute(attribute_name) end |
#magma_client ⇒ Object
13 14 15 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 13 def magma_client magma_crud.magma_client end |
#model_exists?(model_name) ⇒ Boolean
21 22 23 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 21 def model_exists?(model_name) models.model(model_name) end |
#models ⇒ Object
47 48 49 50 51 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 47 def models @models ||= begin magma_client.retrieve(RetrievalRequest.new(project_name: self.project_name, model_name: 'all')).models end end |
#parse_input_file ⇒ Object
17 18 19 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 17 def parse_input_file raise "Must be implemented in a subclass" end |
#update_attributes ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 39 def update_attributes magma_crud.update_records(method: :update_json) do |update_request| each_revision do |model_name, record_name, revision| update_request.update_revision(model_name, record_name, revision) end end end |