Class: UiObjectAnswer

Inherits:
Object
  • Object
show all
Defined in:
lib/question_chain/models/ui_object_answer.rb

Class Method Summary collapse

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.

Parameters:

  • json (String)

Returns:

  • (String)

    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