Module: Quby::Questionnaires::DSL::Questions::Subquestions
- Included in:
- CheckboxQuestionBuilder, RadioQuestionBuilder
- Defined in:
- lib/quby/questionnaires/dsl/questions/base.rb
Instance Method Summary collapse
- #build ⇒ Object
- #initialize(key, options = {}, &block) ⇒ Object
- #question(key, options = {}, &block) ⇒ Object
- #title_question(key, options = {}, &block) ⇒ Object
Instance Method Details
#build ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 119 def build if @title_question @question..last.questions << @title_question @title_question = nil end super end |
#initialize(key, options = {}, &block) ⇒ Object
113 114 115 116 117 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 113 def initialize(key, = {}, &block) super @default_question_options = [:default_question_options] || {} @title_question = nil end |
#question(key, options = {}, &block) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 143 def question(key, = {}, &block) = @default_question_options.merge() .merge(questionnaire: @questionnaire, parent: @question, parent_option_key: @question..last.key) check_question_keys_uniqueness key, , @questionnaire question = QuestionBuilder.build(key, , &block) @questionnaire.register_question(question) @question..last.questions << question end |
#title_question(key, options = {}, &block) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/quby/questionnaires/dsl/questions/base.rb', line 128 def title_question(key, = {}, &block) = @default_question_options.merge({depends_on: @question.key, questionnaire: @questionnaire, parent: @question, presentation: :next_to_title, allow_blank_titles: @question.allow_blank_titles}.merge()) check_question_keys_uniqueness key, , @questionnaire question = QuestionBuilder.build(key, , &block) @questionnaire.register_question(question) @title_question = question end |