Farfetch / rules-framework

A generic framework that allows defining and evaluating rules for complex business scenarios.
MIT License
40 stars 7 forks source link

Rules builder - set logical operator with specific fluent methods #21

Closed luispfgarces closed 12 months ago

luispfgarces commented 3 years ago

When adding composed nodes to rules, the fluent interface available on rules builder is:

(...)
return b.AsComposed()
    .WithLogicalOperator(LogicalOperators.Or)
    .AddCondition(cb =>
(...)

Which creates a experience issue given LogicalsOperators has literals And, Or and Eval. The literal Eval is not valid for composed nodes, but the following configuration is possible:

(...)
return b.AsComposed()
    .WithLogicalOperator(LogicalOperators.Eval)
    .AddCondition(cb =>
(...)

So in order to avoid framework consumers from using the framework this way, the proposal is to deprecate method WithLogicalOperator(LogicalOperators logicalOperator) and expose 2 new specific fluent methods on builder:

Deprecated method would be removed on next major release.

Daniel-C-Dias commented 1 year ago

Will lose scope after the development of https://github.com/Farfetch/rules-framework/issues/138

luispfgarces commented 12 months ago

Resolved by #138.