Class: SurveyGizmo::API::Page

Inherits:
Object
  • Object
show all
Includes:
MultilingualTitle, Resource
Defined in:
lib/survey_gizmo/api/page.rb

Instance Method Summary collapse

Methods included from MultilingualTitle

#title=

Methods included from Resource

descendants, #destroy, #inspect, #reload, #save

Instance Method Details

#questionsObject



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 } } }

  # See note on broken subquestions in resource.rb.
  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

#surveyObject



17
18
19
# File 'lib/survey_gizmo/api/page.rb', line 17

def survey
  @survey ||= Survey.first(id: survey_id)
end