在数据库中存储工作流(状态机).最好的方法是什么? [英] Storing workflows (state machines) in the DB. What's the best way?

查看:45
本文介绍了在数据库中存储工作流(状态机).最好的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 workflow gem (htts://rubygems.org/gems/workflow),在 RoR 模型(用户)中对一个简单的状态机进行建模(实际上许多工作流具有相同的根).

I am using workflow gem (htts://rubygems.org/gems/workflow), inside a RoR model (User) to model a simple state machine (actually many workflow with the same root).

状态机硬编码在模型中,但我需要一种方法来允许管理员自定义工作流程.所以,我认为,我必须找到一种解决方案将所有工作流(状态机)存储到数据库.

The state machine is hardcoded in the model, but I need a way to allow the administrators to customize the workflows. So, I think, that I have to find out a solution to store all the workflows (the state machines) to the DB.

你知道一些 lib 或 gems 来做到这一点吗?(我见过很多状态机 gem,但它们不管理存储在表中的工作流)

Do you know some lib or gems to do that ? (I have seen many state machines gem but they don't manage workflow stored in the tables)

非常感谢

推荐答案

不知道有什么妙招……但是,您可以使用元编程来加载您的工作流的运作方式.

Don't know of any gems... but, you could use meta-programming to load how your workflows function.

假设您可以将工作流定义存储在数据库中.类似的东西:

Let's say you could store your workflow definitions in the database. Something like:

Account.new.extend_workflow(@user.account_workflows)

#extend_workflow 和 account_workflows 是完全自定义的,由您编写...这样,您的帐户就可以拥有自定义状态机定义和规则集.

The #extend_workflow and the account_workflows are completely custom and written by you... in this way, your Account could have custom state machine definitions and rulesets.

不适合胆小的人,但可以在这里解决您的问题.

Not for the faint of heart, but could solve your problem here.

这篇关于在数据库中存储工作流(状态机).最好的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆