Class: Decidim::Surveys::SurveyQuestion
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Surveys::SurveyQuestion
- Defined in:
- app/models/decidim/surveys/survey_question.rb
Overview
The data store for a SurveyQuestion in the Decidim::Surveys component.
Constant Summary collapse
- TYPES =
%w(short_answer long_answer single_option multiple_option sorting).freeze
Instance Method Summary collapse
- #mandatory_body? ⇒ Boolean
- #mandatory_choices? ⇒ Boolean
- #multiple_choice? ⇒ Boolean
- #number_of_options ⇒ Object
Instance Method Details
#mandatory_body? ⇒ Boolean
23 24 25 |
# File 'app/models/decidim/surveys/survey_question.rb', line 23 def mandatory_body? mandatory? && !multiple_choice? end |
#mandatory_choices? ⇒ Boolean
27 28 29 |
# File 'app/models/decidim/surveys/survey_question.rb', line 27 def mandatory_choices? mandatory? && multiple_choice? end |
#multiple_choice? ⇒ Boolean
19 20 21 |
# File 'app/models/decidim/surveys/survey_question.rb', line 19 def multiple_choice? %w(single_option multiple_option sorting).include?(question_type) end |
#number_of_options ⇒ Object
31 32 33 |
# File 'app/models/decidim/surveys/survey_question.rb', line 31 def .size end |