Skip to content

Commit

Permalink
refactor: refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
nf1s committed Feb 1, 2024
1 parent 3f73d6e commit ec34065
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rules_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ def __init__(self, *rules: Rule) -> None:
def run(self, *args: Any, **kwargs: Any) -> Any:
for rule in self.rules:
if rule.condition(*args, **kwargs):
return Result(value=rule.action(*args, **kwargs), message=rule.message)
return Result(rule.action(*args, **kwargs), rule.message)

raise NoMatch

def run_all(self, *args: Any, **kwargs: Any) -> list:
results = [
Result(value=rule.action(*args, **kwargs), message=rule.message)
Result(rule.action(*args, **kwargs), rule.message)
for rule in self.rules
if rule.condition(*args, **kwargs)
]

if not results:
raise NoMatch
return results
Expand Down

0 comments on commit ec34065

Please sign in to comment.