Module: Quby::Compiler::DSL::Questions::MultipleChoice

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

Instance Method Summary collapse

Instance Method Details

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



98
99
100
101
102
103
104
105
106
107
# File 'lib/quby/compiler/dsl/questions/base.rb', line 98

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