Sha256: 85d392f66077a23366232d5a46e39b9db959d7a852f802f38109eba95ec6d655
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
# frozen_string_literal: true module Quby module Questionnaires module Entities class Flag < Struct.new(:key, :description_true, :description_false, :description, :internal, :trigger_on, :shows_questions, :hides_questions, :depends_on, :default_in_interface) # rubocop:disable ParameterLists def initialize(key:, description_true: nil, description_false: nil, description: nil, internal: false, trigger_on: true, shows_questions: [], hides_questions: [], depends_on: nil, # used in interface to hide this flag unless the depended on flag is set to true default_in_interface: nil) # used in interface to set a default for the flag state, # does not have an effect outside of the interface super(key, description_true, description_false, description, internal, trigger_on, shows_questions, hides_questions, depends_on, default_in_interface) ensure_valid_descriptions end # rubocop:enable ParameterLists def if_triggered_by(answer_flags) yield if answer_flags[key] == trigger_on end private def ensure_valid_descriptions unless (description_false.present? && description_true.present?) || description.present? raise "Flag '#{key}' Requires at least either both description_true and description_false or a description" end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quby-5.6.2 | lib/quby/questionnaires/entities/flag.rb |