Class: UiObjectAnswer
- Inherits:
-
Object
- Object
- UiObjectAnswer
- Defined in:
- lib/question_chain/models/ui_object_answer.rb
Class Method Summary collapse
-
.update_answers!(answer_json = "") ⇒ String
Json formatted String manipulate from ui changes.
Class Method Details
.update_answers!(answer_json = "") ⇒ String
TODO:
refactor make not as ugly as a bulldog eating a wasp
Returns json formatted String manipulate from ui changes.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/question_chain/models/ui_object_answer.rb', line 6 def self.update_answers!(answer_json = "") @answer_hash = JSON.parse(answer_json) if @ui_objects = @answer_hash.delete("ui_objects") uis = UiObject.find(ui_object_ids) uis.each do |ui_object| ui_object.change_value!(@ui_objects) end end @answer_hash["ui_objects"] = @ui_objects answer_json = @answer_hash.to_json end |