Module: Quby::Questionnaires::DSL::Questions::MultipleChoice

Included in:
CheckboxQuestionBuilder, DeprecatedQuestionBuilder, RadioQuestionBuilder, SelectQuestionBuilder
Defined in:
lib/quby/questionnaires/dsl/questions/base.rb

Instance Method Summary collapse

Instance Method Details

#option(key, options = {}, &block) ⇒ Object



100
101
102
103
104
105
106
107
108
109
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 100

def option(key, options = {}, &block)
  question_option = Entities::QuestionOption.new(key, @question, options)
  if @questionnaire.key_in_use?(question_option.input_key) || @question.key_in_use?(question_option.input_key)
    fail "#{questionnaire.key}:#{@question.key}:#{question_option.key}: " \
          "A question or option with input key #{question_option.input_key} is already defined."
  end

  @question.options << question_option
  instance_eval(&block) if block
end