Class: Etna::Clients::Magma::UpdateRequest
- Inherits:
-
Struct
- Object
- Struct
- Etna::Clients::Magma::UpdateRequest
- Defined in:
- lib/etna/clients/magma/models.rb
Instance Attribute Summary collapse
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#revisions ⇒ Object
Returns the value of attribute revisions.
Instance Method Summary collapse
- #append_table(parent_model_name, parent_record_name, model_name, attrs, attribute_name = model_name) ⇒ Object
-
#initialize(**params) ⇒ UpdateRequest
constructor
A new instance of UpdateRequest.
- #update_revision(model_name, record_name, attrs) ⇒ Object
Methods included from MultipartSerializableNestedHash
#encode_multipart_content, included
Methods included from JsonSerializableStruct
Constructor Details
#initialize(**params) ⇒ UpdateRequest
Returns a new instance of UpdateRequest.
29 30 31 |
# File 'lib/etna/clients/magma/models.rb', line 29 def initialize(**params) super({revisions: {}}.update(params)) end |
Instance Attribute Details
#project_name ⇒ Object
Returns the value of attribute project_name
25 26 27 |
# File 'lib/etna/clients/magma/models.rb', line 25 def project_name @project_name end |
#revisions ⇒ Object
Returns the value of attribute revisions
25 26 27 |
# File 'lib/etna/clients/magma/models.rb', line 25 def revisions @revisions end |
Instance Method Details
#append_table(parent_model_name, parent_record_name, model_name, attrs, attribute_name = model_name) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/etna/clients/magma/models.rb', line 39 def append_table(parent_model_name, parent_record_name, model_name, attrs, attribute_name = model_name) parent_revision = update_revision(parent_model_name, parent_record_name, {}) table = parent_revision[attribute_name] ||= [] id = "::#{model_name}#{(revisions[model_name] || {}).length + 1}" table << id update_revision(model_name, id, attrs) id end |
#update_revision(model_name, record_name, attrs) ⇒ Object
33 34 35 36 37 |
# File 'lib/etna/clients/magma/models.rb', line 33 def update_revision(model_name, record_name, attrs) revision = revisions[model_name] ||= {} record = revision[record_name] ||= {} record.update(attrs) end |