class ConsolidatedHealthAnswers
Public Class Methods
Source
# File app/models/consolidated_health_answers.rb, line 4 def initialize(objects = []) @answers = {} objects.each { add_answers_from_model(it) } end
Public Instance Methods
Source
# File app/models/consolidated_health_answers.rb, line 10 def add_answer(responder:, question:, answer:, notes: nil) return if answer.nil? @answers[question] ||= [] @answers[question] << { responder:, answer:, notes: } end
Source
# File app/models/consolidated_health_answers.rb, line 27 def to_h consolidated_answers end
Produces responses in the format: {
"Question 1" => [
{ responder: "All", answer: "No" }, # if both Person 1 and Person 2 answered No to Question 1
],
"Question 2" => [
{ responder: "Person 1", answer: "No" },
{ responder: "Person 2", answer: "Yes", notes: "Some notes" }
]
}