RSDComparableSurveyRuleObject
public struct RSDComparableSurveyRuleObject<T> : RSDComparableSurveyRule, Codable where T : Decodable, T : Encodable
RSDComparableSurveyRuleObject
is a survey rule that matches an expected result to the answer and vends a skip
identifier if the match is evaluated to true
.
-
Optional skip identifier for this rule. If available, this will be used as the skip identifier, otherwise the
skipToIdentifier
will be assumed to beRSDIdentifier.exit
Declaration
Swift
public let skipToIdentifier: String?
-
Optional cohort to assign if the rule matches. If available, then an
RSDCohortRule
can be used to track the cohort to assign depending upon how this rule evaluates.Declaration
Swift
public let cohort: String?
-
The rule operator to apply. If
nil
,.equal
will be assumed unless theexpectedAnswer
is also nil, in which case.skip
will be assumed.Declaration
Swift
public let ruleOperator: RSDSurveyRuleOperator?
-
Expected answer for the rule. If
nil
, then the operator must be .skip or this will return a nil value.Declaration
Swift
public var matchingAnswer: Any? { get }
-
Default initializer.
Declaration
Swift
public init(skipToIdentifier: String?, matchingValue: Value?, ruleOperator: RSDSurveyRuleOperator?, cohort: String? = nil)
Parameters
skipToIdentifier
Skip identifier for this rule.
matchingValue
Value-typed matching answer.
ruleOperator
The rule operator to apply.
cohort
The cohort to assign for this rule if it matches.
-
Initialize from a
Decoder
. This method will decode the values and also check that the combination of inputs is valid.Throws
DecodingError
if there is a decoding error.Declaration
Swift
public init(from decoder: Decoder) throws
Parameters
decoder
The decoder to use to decode this instance.