abstract datatype: flag_builder()
A builder for feature flag configurations to be used with ldclient_testdata
.
abstract datatype: flag_rule_builder()
A builder for feature flag rules to be used with flag_builder()
.
variation() = boolean() | non_neg_integer()
and_match/3 | Adds another clause, using the "is one of" operator. |
and_match/4 | Adds another clause, using the "is one of" operator. |
and_not_match/3 | Adds another clause, using the "is not one of" operator. |
and_not_match/4 | Adds another clause, using the "is not one of" operator. |
boolean_flag/1 | A shortcut for setting the flag to use the standard boolean configuration. |
clear_rules/1 | Removes any existing rules from the flag. |
clear_targets/1 | Removes any existing targets from the flag. |
fallthrough_variation/2 | Specifies the fallthrough variation for a flag. |
if_match/3 | Starts defining a flag rule, using the "is one of" operator. |
if_match/4 | Starts defining a flag rule, using the "is one of" operator. |
if_not_match/3 | Starts defining a flag rule, using the "is not one of" operator. |
if_not_match/4 | Starts defining a flag rule, using the "is not one of" operator. |
off_variation/2 | Specifies the off variation for a flag. |
on/2 | Sets targeting to be on or off for this flag. |
then_return/2 | Finishes defining the rule, specifying the result variation. |
value_for_all/2 | Sets the flag to always return the specified variation value for all contexts. |
variation_for_all/2 | Sets the flag to always return the specified variation for all contexts. |
variation_for_context/4 | Sets the flag to return the specified variation for a specific context kind and key when targeting is on. |
variations/2 | Sets the flag to always return the specified variation value for all contexts. |
and_match(ContextAttribute::ldclient_context:attribute_key(), Values::[term()], RuleBuilder::flag_rule_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
RuleBuilder: the rule builder to modify
returns: the modified rule builder
Adds another clause, using the "is one of" operator. The kind of the context is implicitly "user"
for non-user contexts use any_match/4
.
For example, this creates a rule that returns true
if the name is "Patsy" and the
country is "gb":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:and_match(<<"country">>, [<<"gb">>], ldclient_flagbuilder:if_match(<<"name">>, [<<"Patsy">>], Flag)), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
and_match(ContextKind::ldclient_context:kind_value(), ContextAttribute::ldclient_context:attribute_key(), Values::[term()], RuleBuilder::flag_rule_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
RuleBuilder: the rule builder to modify
returns: the modified rule builder
Adds another clause, using the "is one of" operator. The kind of the context is implicitly "user"
for non-user contexts use any_match/4
.
For example, this creates a rule that returns true
if the name is "Patsy" and the
country is "gb":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:and_match(<<"user">>, <<"country">>, [<<"gb">>], ldclient_flagbuilder:if_match(<<"user">>, <<"name">>, [<<"Patsy">>], Flag)), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
and_not_match(ContextAttribute::ldclient_context:attribute_key(), Values::[term()], RuleBuilder::flag_rule_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
RuleBuilder: the rule builder to modify
returns: the modified rule builder
Adds another clause, using the "is not one of" operator. The kind of the context is implicitly "user"
for non-user contexts use any_match/4
.
For example, this creates a rule that returns true
if the name is "Patsy" and the
country is not "gb":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:and_not_match(<<"country">>, [<<"gb">>], ldclient_flagbuilder:if_match(<<"name">>, [<<"Patsy">>], Flag)), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
and_not_match(ContextKind::ldclient_context:kind_value(), ContextAttribute::ldclient_context:attribute_key(), Values::[term()], RuleBuilder::flag_rule_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
RuleBuilder: the rule builder to modify
returns: the modified rule builder
Adds another clause, using the "is not one of" operator.
For example, this creates a rule that returns true
if the name is "Patsy" and the
country is not "gb":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:and_not_match(<<"user">>, <<"country">>, [<<"gb">>], ldclient_flagbuilder:if_match(<<"user">>, <<"name">>, [<<"Patsy">>], Flag)), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
boolean_flag(FlagBuilder::flag_builder()) -> flag_builder()
FlagBuilder: the flag builder to modify
returns: the modified builder
A shortcut for setting the flag to use the standard boolean configuration.
This is the default for all new flags created withldclient_testdata:flag/2
.
The flag will have two variations, true
and false
(in that order); it will return
false
whenever targeting is off, and true
when targeting is on if no other
settings specify otherwise.
clear_rules(FlagBuilder::flag_builder()) -> flag_builder()
FlagBuilder: the flag builder to modify
returns: the modified builder
Removes any existing rules from the flag.
This undoes the effect ofif_match/3
and if_not_match/3
.
clear_targets(FlagBuilder::flag_builder()) -> flag_builder()
FlagBuilder: the flag builder to modify
returns: the modified builder
Removes any existing targets from the flag.
This undoes the effect ofvariation_for_context/4
.
fallthrough_variation(Variation::variation(), FlagBuilder::flag_builder()) -> flag_builder()
Variation: true
, false
, or the index of the desired variation to return: 0 for the first, 1 for the second, etc.
FlagBuilder: the flag builder to modify
returns: the modified builder
Specifies the fallthrough variation for a flag.
The fallthrough is the value that is returned if targeting is on and the user was not matched by a more specific target or rule.
If the flag was previously configured with other variations and a boolean variation is specified, this also changes the flagbuilder to a boolean flag.if_match(ContextAttribute::ldclient_context:attribute_key(), Values::[term()], FlagBuilder::flag_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
FlagBuilder: the flag builder to modify
returns: a flag_rule_builder()
; call then_return/2
to finish the rule,
or add more tests with and_match/4
or and_not_match/4
.
Starts defining a flag rule, using the "is one of" operator. The kind of the context is implicitly "user"
for non-user contexts use if_match/4
.
For example, this creates a rule that returns true
if the name is "Patsy" or "Edina":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:if_match(<<"name">>, [<<"Patsy">>, <<"Edina">>], Flag), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
if_match(ContextKind::ldclient_context:kind_value(), ContextAttribute::ldclient_context:attribute_key(), Values::[term()], FlagBuilder::flag_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
FlagBuilder: the flag builder to modify
returns: a flag_rule_builder()
; call then_return/2
to finish the rule,
or add more tests with and_match/4
or and_not_match/4
.
Starts defining a flag rule, using the "is one of" operator.
For example, this creates a rule that returns true
if the name is "Patsy" or "Edina":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:if_match(<<"user">>, <<"name">>, [<<"Patsy">>, <<"Edina">>], Flag), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
if_not_match(ContextAttribute::ldclient_context:attribute_key(), Values::[term()], FlagBuilder::flag_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
FlagBuilder: the flag builder to modify
returns: a flag_rule_builder()
; call then_return/2
to finish the rule,
or add more tests with and_match/4
or and_not_match/4
.
Starts defining a flag rule, using the "is not one of" operator. The kind of the context is implicitly
"user" for non-user contexts use if_not_match/4
.
For example, this creates a rule that returns true
if the name is neither "Saffron" nor "Bubble":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:if_not_match(<<"name">>, [<<"Saffron">>, <<"Bubble">>], Flag), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
if_not_match(ContextKind::ldclient_context:kind_value(), ContextAttribute::ldclient_context:attribute_key(), Values::[term()], FlagBuilder::flag_builder()) -> flag_rule_builder()
ContextAttribute: the context attribute to match against
Values: values to compare to
FlagBuilder: the flag builder to modify
returns: a flag_rule_builder()
; call then_return/2
to finish the rule,
or add more tests with and_match/4
or and_not_match/4
.
Starts defining a flag rule, using the "is not one of" operator.
For example, this creates a rule that returns true
if the name is neither "Saffron" nor "Bubble":
{ok, Flag} = ldclient_testdata:flag(TestData, <<"flag">>), RuleBuilder = ldclient_flagbuilder:if_not_match(<<"user">>, <<"name">>, [<<"Saffron">>, <<"Bubble">>], Flag), UpdatedFlag = ldclient_flagbuilder:then_return(true, RuleBuilder), ldclient_testdata:update(TestData, UpdatedFlag).
off_variation(Variation::variation(), FlagBuilder::flag_builder()) -> flag_builder()
Variation: true
, false
, or the index of the desired variation to return: 0 for the first, 1 for the second, etc.
FlagBuilder: the flag builder to modify
returns: the modified builder
Specifies the off variation for a flag.
The off variation is the value that is returned whenever targeting is off
If the flag was previously configured with other variations and a boolean Variation is specified, this also changes the FlagBuilder to a boolean flag.on(IsOn::boolean(), FlagBuilder::flag_builder()) -> flag_builder()
IsOn: true if targeting should be on
FlagBuilder: the flag builder to modify
returns: the modified builder
Sets targeting to be on or off for this flag.
The effect of this depends on the rest of the flag configuration, just as it does on the real LaunchDarkly dashboard. In the default configuration that you get from callingldclient_testdata:flag/2
with a new flag key, the flag will return false
whenever targeting is off, and true
when targeting is on.
then_return(Variation::variation(), RuleBuilder::flag_rule_builder()) -> flag_builder()
Variation: true
, false
, or the index of the desired variation to return: 0 for the first, 1 for the second, etc.
RuleBuilder: the rule builder to use
returns: the modified flag builder that initially created this rule builder
Finishes defining the rule, specifying the result variation.
If the flag was previously configured with other variations and a boolean variation is specified, this also changes the FlagBuilder to a boolean flag.value_for_all(Value::term(), FlagBuilder::flag_builder()) -> flag_builder()
Value: the desired value to be returned for all contexts
FlagBuilder: the flag builder to modify
returns: the modified builder
Sets the flag to always return the specified variation value for all contexts.
The value may be of any JSON type, as defined by }. This method changes the flag to have only a single variation, which is this value, and to return the same variation regardless of whether targeting is on or off. Any existing targets or rules are removed.variation_for_all(Variation::variation(), FlagBuilder::flag_builder()) -> flag_builder()
Variation: true
, false
, or the index of the desired variation to return: 0 for the first, 1 for the second, etc.
FlagBuilder: the flag builder to modify
returns: the modified builder
Sets the flag to always return the specified variation for all contexts.
The variation is set, targeting is switched on, and any existing targets or rules are removed. The fallthrough variation is set to the specified value. The off variation is left unchanged.
If the flag was previously configured with other variations and a boolean variation is specified, this also changes the flagbuilder to a boolean flag.variation_for_context(Variation::variation(), ContextKind::ldclient_context:kind_value(), ContextKey::binary(), FlagBuilder::flag_builder()) -> flag_builder()
Variation: true
, false
, or the index of the desired variation to return: 0 for the first, 1 for the second, etc.
ContextKind: the kind of context to target
ContextKey: the key of the context to target
FlagBuilder: the flag builder to modify
returns: the modified builder
Sets the flag to return the specified variation for a specific context kind and key when targeting is on.
This has no effect when targeting is turned off for the flag.
If the flag was previously configured with other variations and a boolean variation is specified, this also changes the flagbuilder to a boolean flag.variations(Values::[ldclient_flag:variation_value()], FlagBuilder::flag_builder()) -> flag_builder()
FlagBuilder: the flag builder to modify
returns: the modified builder
Sets the flag to always return the specified variation value for all contexts.
The value may be of any JSON type. This method changes the flag to have only a single variation, which is this value, and to return the same variation regardless of whether targeting is on or off. Any existing targets or rules are removed.Generated by EDoc