Class: Etna::Clients::Magma::UpdateAttributesFromCsvWorkflowBase
- Inherits:
-
Struct
- Object
- Struct
- Etna::Clients::Magma::UpdateAttributesFromCsvWorkflowBase
show all
- Defined in:
- lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
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
|
#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
|
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 do |update_request|
each_revision do |model_name, record_name, revision|
update_request.update_revision(model_name, record_name, revision)
end
end
end
|