Skip to content

Commit

Permalink
add FeatureFlagBuilder.Prerequisites helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Oct 25, 2024
1 parent 3b0bd2d commit 8a6d14b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkgs/sdk/client/src/DataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal FeatureFlag(
TrackEvents = trackEvents;
TrackReason = trackReason;
DebugEventsUntilDate = debugEventsUntilDate;
Prerequisites = prerequisites;
Prerequisites = prerequisites != null ? new List<string>(prerequisites) : null;
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class FeatureFlagBuilder
private bool _trackReason;
private UnixMillisecondTime? _debugEventsUntilDate;
private EvaluationReason? _reason;
private List<string> _prerequisites;

public FeatureFlagBuilder()
{
Expand All @@ -30,11 +31,12 @@ public FeatureFlagBuilder(FeatureFlag from)
_trackReason = from.TrackReason;
_debugEventsUntilDate = from.DebugEventsUntilDate;
_reason = from.Reason;
_prerequisites = from.Prerequisites != null ? new List<string>(from.Prerequisites) : null;
}

public FeatureFlag Build()
{
return new FeatureFlag(_value, _variation, _reason, _version, _flagVersion, _trackEvents, _trackReason, _debugEventsUntilDate);
return new FeatureFlag(_value, _variation, _reason, _version, _flagVersion, _trackEvents, _trackReason, _debugEventsUntilDate, _prerequisites);
}

public FeatureFlagBuilder Value(LdValue value)
Expand Down Expand Up @@ -88,6 +90,18 @@ public FeatureFlagBuilder DebugEventsUntilDate(UnixMillisecondTime? debugEventsU
_debugEventsUntilDate = debugEventsUntilDate;
return this;
}

public FeatureFlagBuilder Prerequisites(params string[] prerequisites)
{
if (prerequisites == null || prerequisites.Length == 0)
{
_prerequisites = null;
return this;
}

_prerequisites = new List<string>(prerequisites);
return this;
}
}

internal class DataSetBuilder
Expand Down

0 comments on commit 8a6d14b

Please sign in to comment.