Class: SurveyGizmo::API::Page
Instance Method Summary
collapse
#title=
Methods included from Resource
descendants, #destroy, #inspect, #reload, #save
Instance Method Details
#questions ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/survey_gizmo/api/page.rb', line 21
def questions
@questions.each { |q| q.attributes = children_params }
return @questions if @questions.all? { |q| q.sub_question_skus.all? { |sku| @questions.find { |q| q.id == sku } } }
with_subquestions = @questions
@questions.each do |q|
with_subquestions.reject! { |q| q.sub_question_skus.include?(q.id) }
with_subquestions += q.sub_questions
end
@questions = with_subquestions.each { |q| q.attributes = children_params }
end
|
#survey ⇒ Object
17
18
19
|
# File 'lib/survey_gizmo/api/page.rb', line 17
def survey
@survey ||= Survey.first(id: survey_id)
end
|