Class: Promethee::StructureUpgrader::Components::Table

Inherits:
Base
  • Object
show all
Defined in:
app/services/promethee/structure_upgrader/components/table.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #upgraded_data

Constructor Details

This class inherits a constructor from Promethee::StructureUpgrader::Components::Base

Instance Method Details

#upgradeObject



17
18
19
20
21
22
23
24
25
26
# File 'app/services/promethee/structure_upgrader/components/table.rb', line 17

def upgrade
  @upgraded_data = @data.deep_dup
  return if @upgraded_data['attributes'].empty?

  attribute('cols').nil?  ? generate_cell_matrix_from_data
                          : generate_cell_matrix_from_structure

  @upgraded_data['attributes'] = upgraded_attributes.deep_stringify_keys
  @upgraded_data['children'] = @cell_matrix.flatten
end

#upgraded_attributesObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/services/promethee/structure_upgrader/components/table.rb', line 28

def upgraded_attributes
  uuid_matrix = @cell_matrix.map { |row| row.map { |cell| cell['id'] } }

  {
    'structure' => {
      'searchable' => false,
      'translatable' => false,
      'type' => 'matrix',
      'value' => uuid_matrix
    }
  }
end