Module: Shared::MatrixHooks

Extended by:
ActiveSupport::Concern
Included in:
Tag
Defined in:
app/models/concerns/shared/matrix_hooks.rb

Overview

Code to update matrix content based on what goes on with this instance.

Classes that include this module must implement

matrix_column_item
matrix_row_item

that returns a single hash containing the matrix_column/row_item and its descriptor/object or false/nil. eg matrix_column_item, “descriptor”: descriptor, or false eg matrix_row_item, “object”: object, or false

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) cleanup_matrix



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/concerns/shared/matrix_hooks.rb', line 36

def cleanup_matrix 
  if matrix_column_item
    mci = matrix_column_item[:matrix_column_item]
    descriptor = matrix_column_item[:descriptor]

    mci.cleanup_single_matrix_column(descriptor.id)
  end

  if matrix_row_item
    mri = matrix_row_item[:matrix_row_item]
    object = matrix_row_item[:object]

    mri.cleanup_single_matrix_row(object)
  end
end

- (Object) update_matrix



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/concerns/shared/matrix_hooks.rb', line 20

def update_matrix
  if matrix_column_item
    mci = matrix_column_item[:matrix_column_item]
    descriptor = matrix_column_item[:descriptor]

    mci.update_single_matrix_column(descriptor)
  end

  if matrix_row_item
    mri = matrix_row_item[:matrix_row_item]
    object = matrix_row_item[:object]

    mri.update_single_matrix_row(object)
  end
end