Sha256: 155d2639e34491e7b56a04f1637a8dc56a33416463be1a2a9a28a13a63d000cd
Contents?: true
Size: 1.35 KB
Versions: 32
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true require 'quby/compiler/entities' module Quby module Compiler module DSL class TableBuilder prepend CallsCustomMethods include Helpers def initialize(panel, default_question_options: {}, **options) @panel = panel @table = Entities::Table.new(options) @default_question_options = default_question_options @panel.items << @table end def title(value) @table.title = value end def description(value) @table.description = value end def text(value, **options) @table.items << Entities::Text.new(value.to_s, options) end def question(key, **options, &block) options = @default_question_options.merge(options) .merge(table: @table, questionnaire: @panel.questionnaire) check_question_keys_uniqueness key, options, @panel.questionnaire fail "You can't create a slider in a table at the moment" if options[:as] == :slider question = QuestionBuilder.build(key, **options, &block) @panel.questionnaire.register_question(question) @table.items << question @panel.items << question end end end end end
Version data entries
32 entries across 32 versions & 1 rubygems