ruby on Rails 的动态业务规则引擎

发布于 2024-09-30 10:12:56 字数 236 浏览 5 评论 0原文

我有一个应用程序需要“动态业务规则”引擎。一些业务规则变化非常频繁。其中一些人会申请一组有限的企业帐户。例如:我的客户有一个流程,根据商店的规模、销售人员的数量、产品的数量、位置等来确定商店的资格。但他管理着不同的帐户,每个帐户对每个属性赋予不同的“权重”。

如何使用 Ruby 实现该引擎?我知道 Java 很让人流口水,但我觉得流口水很烦人而且很复杂。我宁愿不必使用 JRuby...

问候,

Rubem

I have an application which will require a "dynamic business rules" engine. Some of the business rules changes very frequently. Some of then applies for a limited set of business accounts. For example: my customer have a process where they qualify stores, based on their size, number of the sales person, number of products, location, etc. But he manages different account, and each account give different "weights" to each attribute.

How do I implement this engine using Ruby? I know Java has drools, but I find drools annoying and complex. And I prefer not having to use JRuby...

Regards,

Rubem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单爱 2024-10-07 10:12:56

如果您确定需要一个规则引擎,则需要找到一个可以在 Ruby 中使用的引擎。通过 Google 快速搜索,找到了 Rools (http://rools.rubyforge.org/) 和 Ruby Rules (http://xircles.codehaus.org/projects/ruby-rules)。但我不确定这两个项目的状态。将 JRuby 与 Drools 结合使用可能是您最好的选择,但话又说回来,我是一名 Java 开发人员,也是 Drools 的大力倡导者。 :)

在不了解所有细节的情况下,很难说应该如何实现。它还取决于您希望如何更新规则。一种方法是编写一组与此类似的规则:“如果商店拥有超过 50 名销售人员,并且该商店尚未更新其权重来反映这一点,则更新商店的权重。”但是,在某种程度上,您可以将其与硬编码进行比较。

更好的方法可能是创建具有应用权重需要满足的条件的 Weight 对象。然后,您可以编写一条同时匹配权重和商店的规则:“如果存在与权重条件匹配的商店,并且该商店尚未分配该权重,则将权重添加到商店。”然后,业务人员可以只创建和更新权重(可能在 Web 前端数据库中),而不用维护规则。

If you're sure a rule engine is what you need, you will need to find one you can use in Ruby. A quick Google search brought up Rools (http://rools.rubyforge.org/) and Ruby Rules (http://xircles.codehaus.org/projects/ruby-rules). I'm not sure of the status of either project though. Using JRuby with Drools might be your best bet but then again, I'm a Java developer and a big Drools advocate. :)

Without knowing all the details, it's a little hard to say how that should be implemented. It also depends on how you want the rules to be updated. One approach is to write a collection of rules similar to this: "if a store exists with more than 50 sales people and the store hasn't had its weight updated to reflect that, then update the store's weight." However, in some way you could compare that to hardcoding.

A better approach might be to create Weight objects with criteria that need to be met for the weight to apply. Then you could write one rule that matches on both Weights and Stores: "if a Store exists that matches a Weight's criteria and the Store doesn't already have that Weight assigned to it, then add the Weigh to the Store." Then the business folks could just create and update Weights, possibly in a web front-ended database, instead of maintaining rules.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文