Sha256: a708823ec8c00e73e02c81fef4dbe41afe39cd5b0e07a214cfe1f9ff32437718

Contents?: true

Size: 666 Bytes

Versions: 48

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Surveys
    # The data store for a SurveyQuestion in the Decidim::Surveys component.
    class SurveyQuestion < Surveys::ApplicationRecord
      TYPES = %w(short_answer long_answer single_option multiple_option).freeze

      belongs_to :survey, class_name: "Survey", foreign_key: "decidim_survey_id"

      validates :question_type, inclusion: { in: TYPES }

      # Rectify can't handle a hash when using the from_model method so
      # the answer options must be converted to struct.
      def answer_options
        self[:answer_options].map { |option| OpenStruct.new(option) }
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
decidim-surveys-0.10.1 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.10.0 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.9.3 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.9.2 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.9.1 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.9.0 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.8.4 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.8.3 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.8.2 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.8.1 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.8.0 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.7.4 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.7.3 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.7.2 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.7.1 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.7.0 app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.6.8 app/models/decidim/surveys/survey_question.rb
decidim-0.6.8 decidim-surveys/app/models/decidim/surveys/survey_question.rb
decidim-surveys-0.6.7 app/models/decidim/surveys/survey_question.rb
decidim-0.6.7 decidim-surveys/app/models/decidim/surveys/survey_question.rb