Class: Rules::AttributeChange
- Defined in:
- lib/question_chain/models/rules/attribute_change.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#fire!(value, ui_objects) ⇒ Object
Checks to determine the value and the fire_value if cool then the ui objects are updated depending on the affecting values.
Methods inherited from Rule
Class Method Details
.attributes_for_api ⇒ Object
7 8 9 |
# File 'lib/question_chain/models/rules/attribute_change.rb', line 7 def self.attributes_for_api %w(id fire_value _type affecting_ui_objects ui_object_id negate_value compare_text_value) end |
Instance Method Details
#fire!(value, ui_objects) ⇒ Object
Checks to determine the value and the fire_value if cool then the ui objects are updated depending on the affecting values
@param [Array<Hash>] ui_objects
17 18 19 20 21 22 23 24 25 |
# File 'lib/question_chain/models/rules/attribute_change.rb', line 17 def fire!(value, ui_objects) if negate_value ? value != self.fire_value : value == self.fire_value affecting_ui_objects.each_pair do |key, value| if ui_object = ui_objects.detect{|ui| ui["id"] == key} ui_object["ui_attributes"].merge!(value) end end end end |