refactor: extract class RuleFactory