Skip to content

Instantly share code, notes, and snippets.

@antonvolkoff
Created January 19, 2020 14:35
Show Gist options
  • Save antonvolkoff/b111e0f6a98f509dd3855acf116bda06 to your computer and use it in GitHub Desktop.
Save antonvolkoff/b111e0f6a98f509dd3855acf116bda06 to your computer and use it in GitHub Desktop.
Rules for switchboard
class Rule {
private operations: Array<any>;
constructor() {
this.operations = [];
}
filter(options): Rule {
this.operations.push({ action: 'filter', options });
return this;
}
store(options): Rule {
this.operations.push({ action: 'store', options });
return this;
}
send(options): Rule {
this.operations.push({ action: 'send', options });
return this;
}
}
const rule = () => new Rule();
rule().filter({ to: "outpostr.com" }).send({ adapter: "outpostr" });
rule().filter({ from: "outpostr.com" }).send({ adapter: "mailgun" });
rule().filter({ from: "antonvolkoff.com" }).send({ adapter: "mailgun" });
rule().filter({ to: "antonvolkoff.com" }).send({ adapter: "outpostr" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment