Sha256: dac1855ae17f821efe738e3a0a294c34173803c6020cb05f641794444efd4f9b
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
module SurveyGizmo; module API # @see SurveyGizmo::Resource::ClassMethods class Question include SurveyGizmo::Resource include SurveyGizmo::MultilingualTitle attribute :id, Integer attribute :type, String attribute :description, String attribute :shortname, String attribute :properties, Hash attribute :after, Integer attribute :survey_id, Integer attribute :page_id, Integer, default: 1 attribute :sub_question_skus, Array attribute :parent_question_id, Integer alias_attribute :_subtype, :type route '/survey/:survey_id/surveyquestion/:id', via: :get route '/survey/:survey_id/surveypage/:page_id/surveyquestion', via: :create route '/survey/:survey_id/surveypage/:page_id/surveyquestion/:id', via: [:update, :delete] def survey @survey ||= Survey.first(id: survey_id) end def options @options ||= Option.all(survey_id: survey_id, page_id: page_id, question_id: id, all_pages: true) end def parent_question @parent_question ||= parent_question_id ? Question.first(survey_id: survey_id, id: parent_question_id) : nil end def sub_questions @sub_questions ||= sub_question_skus.map { |subquestion_id| Question.first(survey_id: survey_id, id: subquestion_id) } .each { |subquestion| subquestion.parent_question_id = id } end # @see SurveyGizmo::Resource#to_param_options def to_param_options { id: self.id, survey_id: self.survey_id, page_id: self.page_id } end end end; end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
survey-gizmo-ruby-4.1.0 | lib/survey_gizmo/api/question.rb |