|
|
|
@ -385,25 +385,25 @@ private |
|
|
|
def reset_derived_questions! |
|
|
|
def reset_derived_questions! |
|
|
|
dependencies = [ |
|
|
|
dependencies = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
parent_conditions: [ |
|
|
|
conditions: { |
|
|
|
{ attribute: :buylivein, value: 2 }, |
|
|
|
buylivein: 2, |
|
|
|
], |
|
|
|
}, |
|
|
|
derived_attributes: %i[buy1livein buy2livein], |
|
|
|
derived_attributes: %i[buy1livein buy2livein], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
parent_conditions: [ |
|
|
|
conditions: { |
|
|
|
{ attribute: :buylivein, value: 1 }, |
|
|
|
buylivein: 1, |
|
|
|
{ attribute: :jointpur, value: 1 }, |
|
|
|
jointpur: 1, |
|
|
|
], |
|
|
|
}, |
|
|
|
derived_attributes: [:buy1livein], |
|
|
|
derived_attributes: [:buy1livein], |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
dependencies.each do |dependency| |
|
|
|
dependencies.each do |dependency| |
|
|
|
any_parent_attributes_changed = dependency[:parent_conditions].any? { |parent_condition| send("#{parent_condition[:attribute]}_changed?") } |
|
|
|
any_primary_attributes_changed = dependency[:conditions].any? { |attribute, _value| send("#{attribute}_changed?") } |
|
|
|
next unless any_parent_attributes_changed |
|
|
|
next unless any_primary_attributes_changed |
|
|
|
|
|
|
|
|
|
|
|
previously_in_derived_state = dependency[:parent_conditions].all? { |parent_condition| send("#{parent_condition[:attribute]}_was") == parent_condition[:value] } |
|
|
|
previously_in_derived_state = dependency[:conditions].all? { |attribute, value| send("#{attribute}_was") == value } |
|
|
|
next unless previously_in_derived_state |
|
|
|
next unless previously_in_derived_state |
|
|
|
|
|
|
|
|
|
|
|
dependency[:derived_attributes].each do |derived_attribute| |
|
|
|
dependency[:derived_attributes].each do |derived_attribute| |
|
|
|
|