Is there a way to load the rules from an external source? I tried
making my SampleRulebook take in block where the block was a simple
load('filename'), but that doesnt work. I know that there is an effort
underway to create an external dsl using treetop but my question is a
bit different. I would like to be able to define the rule blocks in
an external file..like a text file. Then in the code create the
engine..create the rulebook..and somehow say load these rules.
Something like:
engine :engine do |e|
rulebook = SampleRulebook.new(e)
rulebook.load('sample_rulebook.ruleby')
e.assert Message.new(:HELLO, 'Hello World')
e.match
end
//contents of rules.ruleby
rule :hello, [Message, :m, method.status == :HELLO] do |context|
puts context[:m].message
end
> Is there a way to load the rules from an external source? I tried
> making my SampleRulebook take in block where the block was a simple
> load('filename'), but that doesnt work. I know that there is an effort
> underway to create an external dsl using treetop but my question is a
> bit different. I would like to be able to define the rule blocks in
> an external file..like a text file. Then in the code create the
> engine..create the rulebook..and somehow say load these rules.
> Something like:
> engine :engine do |e|
> rulebook = SampleRulebook.new(e)
> rulebook.load('sample_rulebook.ruleby')
> e.assert Message.new(:HELLO, 'Hello World')
> e.match
> end
> //contents of rules.ruleby
> rule :hello, [Message, :m, method.status == :HELLO] do |context|
> puts context[:m].message
> end
Ok i put the eval in the actual SampleRulebook class...i think i like
this better because the client accessing the rules doesnt know where
the rules are defined...which i like. So now I have:
engine :engine do |e|
e.assert Message.new(:HELLO, 'Hello World')
mrb = SampleRulebook.new(e)
mrb.rules
e.match
end
class SimpleRulebook < Rulebook
attr :messages
def initialize(e, &block)
@messages = []
super(e)
yield self if block_given?
end
def rules
path =File.join(File.dirname(__FILE__), 'rules/*.ruleby')
Dir[path].each do |f|
eval((IO.readlines(f, '').to_s))
end
end
end
On Oct 26, 11:52 am, Jake Dempsey <angelo0...@gmail.com> wrote:
> I got this to work..not sure if its the best approach..eval always
> makes me worried. Can you think of another way of doing it in a safer
> way?
> engine :engine do |e|
> e.assert Message.new(:HELLO, 'Hello World')
> mrb = SampleRulebook.new(e)
> mrb.class.class_eval do
> def rules
> eval(IO.readlines(File.join(File.dirname(__FILE__),
> 'rules.ruleby'), '').to_s)
> end
> end
> mrb.rules
> e.match
> end
> //contents of rules.ruleby
> rule :hello, [Message, :m, method.status == :HELLO] do |context|
> puts context[:m].message
> end
> On Oct 26, 10:56 am, Jake Dempsey <angelo0...@gmail.com> wrote:
> > Is there a way to load the rules from an external source? I tried
> > making my SampleRulebook take in block where the block was a simple
> > load('filename'), but that doesnt work. I know that there is an effort
> > underway to create an external dsl using treetop but my question is a
> > bit different. I would like to be able to define the rule blocks in
> > an external file..like a text file. Then in the code create the
> > engine..create the rulebook..and somehow say load these rules.
> > Something like:
While I was reading the doc recently I did notice a method which may
be a better way to go for this,
but I have not got around to figuring out how to do it.:
assert_rule(rule)
This method is invoked when a new rule is added to the system. The
rule is processed and the appropriate nodes are added to the network.
> Ok i put the eval in the actual SampleRulebook class...i think i like
> this better because the client accessing the rules doesnt know where
> the rules are defined...which i like. So now I have:
> engine :engine do |e|
> e.assert Message.new(:HELLO, 'Hello World')
> mrb = SampleRulebook.new(e)
> mrb.rules
> e.match
> end
> class SimpleRulebook < Rulebook
> attr :messages
> def initialize(e, &block)
> @messages = []
> super(e)
> yield self if block_given?
> end
> def rules
> path =File.join(File.dirname(__FILE__), 'rules/*.ruleby')
> Dir[path].each do |f|
> eval((IO.readlines(f, '').to_s))
> end
> end
> end
> On Oct 26, 11:52 am, Jake Dempsey <angelo0...@gmail.com> wrote:
>> I got this to work..not sure if its the best approach..eval always
>> makes me worried. Can you think of another way of doing it in a
>> safer
>> way?
>> engine :engine do |e|
>> e.assert Message.new(:HELLO, 'Hello World')
>> mrb = SampleRulebook.new(e)
>> mrb.class.class_eval do
>> def rules
>> eval(IO.readlines(File.join(File.dirname(__FILE__),
>> 'rules.ruleby'), '').to_s)
>> end
>> end
>> mrb.rules
>> e.match
>> end
>> //contents of rules.ruleby
>> rule :hello, [Message, :m, method.status == :HELLO] do |context|
>> puts context[:m].message
>> end
>> On Oct 26, 10:56 am, Jake Dempsey <angelo0...@gmail.com> wrote:
>>> Is there a way to load the rules from an external source? I tried
>>> making my SampleRulebook take in block where the block was a simple
>>> load('filename'), but that doesnt work. I know that there is an
>>> effort
>>> underway to create an external dsl using treetop but my question
>>> is a
>>> bit different. I would like to be able to define the rule blocks in
>>> an external file..like a text file. Then in the code create the
>>> engine..create the rulebook..and somehow say load these rules.
>>> Something like:
>>> engine :engine do |e|
>>> rulebook = SampleRulebook.new(e)
>>> rulebook.load('sample_rulebook.ruleby')
>>> e.assert Message.new(:HELLO, 'Hello World')
>>> e.match
>>> end
>>> //contents of rules.ruleby
>>> rule :hello, [Message, :m, method.status == :HELLO] do |context|
>>> puts context[:m].message
>>> end
These are both very interesting ways of building your rule base.
While they seem to work for the two of you, they make me feel like the
Rulebook design is lacking something. I would greatly welcome your
suggestions on how to improve it for these kinds of cases.
The assert_rule method take a Rule object as a parameter. The Rule
class is not complicated, and the DSL simply builds one of these up
behind the scenes. You can see an example of this around line 130 in
ferrari.rb
On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
> I am doing something similar, I have the rules written in a code field in an
> events table in rails.
> @event = Event.find_by_title(f)
> engine :engine do |e|
> TestRulebook.class_eval "def rules;" + @event.code + ";end;"
> TestRulebook.new(e).rules
> ...etc
> While I was reading the doc recently I did notice a method which may be a
> better way to go for this,
> but I have not got around to figuring out how to do it.:
> assert_rule(rule)
> This method is invoked when a new rule is added to the system. The rule is
> processed and the appropriate nodes are added to the network.
> - Ric
> On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
> Ok i put the eval in the actual SampleRulebook class...i think i like
> this better because the client accessing the rules doesnt know where
> the rules are defined...which i like. So now I have:
> engine :engine do |e|
> e.assert Message.new(:HELLO, 'Hello World')
> mrb = SampleRulebook.new(e)
> mrb.rules
> e.match
> end
> class SimpleRulebook < Rulebook
> attr :messages
> def initialize(e, &block)
> @messages = []
> super(e)
> yield self if block_given?
> end
> def rules
> path =File.join(File.dirname(__FILE__), 'rules/*.ruleby')
> Dir[path].each do |f|
> eval((IO.readlines(f, '').to_s))
> end
> end
> end
> On Oct 26, 11:52 am, Jake Dempsey <angelo0...@gmail.com> wrote:
> I got this to work..not sure if its the best approach..eval always
> makes me worried. Can you think of another way of doing it in a safer
I am looking at ruleby as a two part module. The first piece I want to
use it for is the execution of a ruleset. The actual rules management
should be externalized in my case. In an environment where customers
drive the rules you want them to be able to change those rules without
the need of a deployment or a svn commit. I have been noodling how I
can use ruleby and remove the need for a larger implementation such as
drools.
The basic workflow I am after is:
Customer manages rules through a webui that persists their rules.
Ideally this would be done with a dsl specific to my application
domain and I have not yet figured out how best to approach this. I
really would like a grammar for my customer that generates ruleby
syntax. My app would start with a constant rule engine and empty
rulebook. On startup the persisted rules would be loaded. At some
point, either event based or time based, I would want to clear the
current rules and reload them. (this is because the customer may have
modified, added, or removed a rule). I dont want to have to create a
new engine (which blows away my working memory). Ideally I would have
a method .reset_rules on my rulebook that would remove all existing
rules and then calls .rules. This would allow me to keep a single
engine/rulebook and use my rule engine as a webservice where my users
can assert and retract facts at any point and each assert doesnt
create the need to create a new engine and reload all the rules.
Hope that explains what I'm after.
On Oct 27, 8:40 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> These are both very interesting ways of building your rule base.
> While they seem to work for the two of you, they make me feel like the
> Rulebook design is lacking something. I would greatly welcome your
> suggestions on how to improve it for these kinds of cases.
> The assert_rule method take a Rule object as a parameter. The Rule
> class is not complicated, and the DSL simply builds one of these up
> behind the scenes. You can see an example of this around line 130 in
> ferrari.rb
> Joe
> On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
> > I am doing something similar, I have the rules written in a code field in an
> > events table in rails.
> > @event = Event.find_by_title(f)
> > engine :engine do |e|
> > TestRulebook.class_eval "def rules;" + @event.code + ";end;"
> > TestRulebook.new(e).rules
> > ...etc
> > While I was reading the doc recently I did notice a method which may be a
> > better way to go for this,
> > but I have not got around to figuring out how to do it.:
> > assert_rule(rule)
> > This method is invoked when a new rule is added to the system. The rule is
> > processed and the appropriate nodes are added to the network.
> > - Ric
> > On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
> > Ok i put the eval in the actual SampleRulebook class...i think i like
> > this better because the client accessing the rules doesnt know where
> > the rules are defined...which i like. So now I have:
I started working on this several times, but never ended up with a good
solution.
The ActiveRule code, http://github.com/mattup/activerule , was intending to
do something similar. The idea was to store the rules in the db, including
any metadata for each rule. I did manage to create a simple ActiveRecord
model as a base. The model works in terms of loading the rule from the db.
But as you point out there is not a way to reload the rules without creating
a new engine.
Another approach I took was to create an external DSL, but sadly I never
finished it either. Sort of a pattern of mine.....
On Wed, Oct 28, 2009 at 7:45 AM, Jake Dempsey <angelo0...@gmail.com> wrote:
> I am looking at ruleby as a two part module. The first piece I want to
> use it for is the execution of a ruleset. The actual rules management
> should be externalized in my case. In an environment where customers
> drive the rules you want them to be able to change those rules without
> the need of a deployment or a svn commit. I have been noodling how I
> can use ruleby and remove the need for a larger implementation such as
> drools.
> The basic workflow I am after is:
> Customer manages rules through a webui that persists their rules.
> Ideally this would be done with a dsl specific to my application
> domain and I have not yet figured out how best to approach this. I
> really would like a grammar for my customer that generates ruleby
> syntax. My app would start with a constant rule engine and empty
> rulebook. On startup the persisted rules would be loaded. At some
> point, either event based or time based, I would want to clear the
> current rules and reload them. (this is because the customer may have
> modified, added, or removed a rule). I dont want to have to create a
> new engine (which blows away my working memory). Ideally I would have
> a method .reset_rules on my rulebook that would remove all existing
> rules and then calls .rules. This would allow me to keep a single
> engine/rulebook and use my rule engine as a webservice where my users
> can assert and retract facts at any point and each assert doesnt
> create the need to create a new engine and reload all the rules.
> Hope that explains what I'm after.
> On Oct 27, 8:40 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> > These are both very interesting ways of building your rule base.
> > While they seem to work for the two of you, they make me feel like the
> > Rulebook design is lacking something. I would greatly welcome your
> > suggestions on how to improve it for these kinds of cases.
> > The assert_rule method take a Rule object as a parameter. The Rule
> > class is not complicated, and the DSL simply builds one of these up
> > behind the scenes. You can see an example of this around line 130 in
> > ferrari.rb
> > Joe
> > On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
> > > I am doing something similar, I have the rules written in a code field
> in an
> > > events table in rails.
> > > @event = Event.find_by_title(f)
> > > engine :engine do |e|
> > > TestRulebook.class_eval "def rules;" + @event.code + ";end;"
> > > TestRulebook.new(e).rules
> > > ...etc
> > > While I was reading the doc recently I did notice a method which may be
> a
> > > better way to go for this,
> > > but I have not got around to figuring out how to do it.:
> > > assert_rule(rule)
> > > This method is invoked when a new rule is added to the system. The rule
> is
> > > processed and the appropriate nodes are added to the network.
> > > - Ric
> > > On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
> > > Ok i put the eval in the actual SampleRulebook class...i think i like
> > > this better because the client accessing the rules doesnt know where
> > > the rules are defined...which i like. So now I have:
Yeah I would think the external dsl would be more valuable. I looked
at activerule but I dont think its needed. If a user defines a rule
using a dsl you could "compile" them in to ruleby rule definitions in
a flat file and just load those at runtime. At least that was my
thought :)
On Oct 28, 9:50 am, Matt Smith <codeaspe...@gmail.com> wrote:
> I started working on this several times, but never ended up with a good
> solution.
> The ActiveRule code,http://github.com/mattup/activerule, was intending to
> do something similar. The idea was to store the rules in the db, including
> any metadata for each rule. I did manage to create a simple ActiveRecord
> model as a base. The model works in terms of loading the rule from the db.
> But as you point out there is not a way to reload the rules without creating
> a new engine.
> Another approach I took was to create an external DSL, but sadly I never
> finished it either. Sort of a pattern of mine.....
> Matt
> On Wed, Oct 28, 2009 at 7:45 AM, Jake Dempsey <angelo0...@gmail.com> wrote:
> > I am looking at ruleby as a two part module. The first piece I want to
> > use it for is the execution of a ruleset. The actual rules management
> > should be externalized in my case. In an environment where customers
> > drive the rules you want them to be able to change those rules without
> > the need of a deployment or a svn commit. I have been noodling how I
> > can use ruleby and remove the need for a larger implementation such as
> > drools.
> > The basic workflow I am after is:
> > Customer manages rules through a webui that persists their rules.
> > Ideally this would be done with a dsl specific to my application
> > domain and I have not yet figured out how best to approach this. I
> > really would like a grammar for my customer that generates ruleby
> > syntax. My app would start with a constant rule engine and empty
> > rulebook. On startup the persisted rules would be loaded. At some
> > point, either event based or time based, I would want to clear the
> > current rules and reload them. (this is because the customer may have
> > modified, added, or removed a rule). I dont want to have to create a
> > new engine (which blows away my working memory). Ideally I would have
> > a method .reset_rules on my rulebook that would remove all existing
> > rules and then calls .rules. This would allow me to keep a single
> > engine/rulebook and use my rule engine as a webservice where my users
> > can assert and retract facts at any point and each assert doesnt
> > create the need to create a new engine and reload all the rules.
> > Hope that explains what I'm after.
> > On Oct 27, 8:40 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> > > These are both very interesting ways of building your rule base.
> > > While they seem to work for the two of you, they make me feel like the
> > > Rulebook design is lacking something. I would greatly welcome your
> > > suggestions on how to improve it for these kinds of cases.
> > > The assert_rule method take a Rule object as a parameter. The Rule
> > > class is not complicated, and the DSL simply builds one of these up
> > > behind the scenes. You can see an example of this around line 130 in
> > > ferrari.rb
> > > Joe
> > > On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
> > > > I am doing something similar, I have the rules written in a code field
> > in an
> > > > events table in rails.
> > > > @event = Event.find_by_title(f)
> > > > engine :engine do |e|
> > > > TestRulebook.class_eval "def rules;" + @event.code + ";end;"
> > > > TestRulebook.new(e).rules
> > > > ...etc
> > > > While I was reading the doc recently I did notice a method which may be
> > a
> > > > better way to go for this,
> > > > but I have not got around to figuring out how to do it.:
> > > > assert_rule(rule)
> > > > This method is invoked when a new rule is added to the system. The rule
> > is
> > > > processed and the appropriate nodes are added to the network.
> > > > - Ric
> > > > On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
> > > > Ok i put the eval in the actual SampleRulebook class...i think i like
> > > > this better because the client accessing the rules doesnt know where
> > > > the rules are defined...which i like. So now I have:
> I am looking at ruleby as a two part module. The first piece I want to
> use it for is the execution of a ruleset. The actual rules management
> should be externalized in my case. In an environment where customers
> drive the rules you want them to be able to change those rules without
> the need of a deployment or a svn commit. I have been noodling how I
> can use ruleby and remove the need for a larger implementation such as
> drools.
> The basic workflow I am after is:
> Customer manages rules through a webui that persists their rules.
> Ideally this would be done with a dsl specific to my application
> domain and I have not yet figured out how best to approach this. I
> really would like a grammar for my customer that generates ruleby
> syntax. My app would start with a constant rule engine and empty
> rulebook. On startup the persisted rules would be loaded. At some
> point, either event based or time based, I would want to clear the
> current rules and reload them. (this is because the customer may have
> modified, added, or removed a rule). I dont want to have to create a
> new engine (which blows away my working memory). Ideally I would have
> a method .reset_rules on my rulebook that would remove all existing
> rules and then calls .rules. This would allow me to keep a single
> engine/rulebook and use my rule engine as a webservice where my users
> can assert and retract facts at any point and each assert doesnt
> create the need to create a new engine and reload all the rules.
> Hope that explains what I'm after.
> On Oct 27, 8:40 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> > These are both very interesting ways of building your rule base.
> > While they seem to work for the two of you, they make me feel like the
> > Rulebook design is lacking something. I would greatly welcome your
> > suggestions on how to improve it for these kinds of cases.
> > The assert_rule method take a Rule object as a parameter. The Rule
> > class is not complicated, and the DSL simply builds one of these up
> > behind the scenes. You can see an example of this around line 130 in
> > ferrari.rb
> > Joe
> > On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
> > > I am doing something similar, I have the rules written in a code field in an
> > > events table in rails.
> > > @event = Event.find_by_title(f)
> > > engine :engine do |e|
> > > TestRulebook.class_eval "def rules;" + @event.code + ";end;"
> > > TestRulebook.new(e).rules
> > > ...etc
> > > While I was reading the doc recently I did notice a method which may be a
> > > better way to go for this,
> > > but I have not got around to figuring out how to do it.:
> > > assert_rule(rule)
> > > This method is invoked when a new rule is added to the system. The rule is
> > > processed and the appropriate nodes are added to the network.
> > > - Ric
> > > On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
> > > Ok i put the eval in the actual SampleRulebook class...i think i like
> > > this better because the client accessing the rules doesnt know where
> > > the rules are defined...which i like. So now I have:
On Fri, Nov 13, 2009 at 9:34 AM, jhc <placidpun...@gmail.com> wrote:
> I'm just starting to play around with Ruleby, so I may be off here.
> But wouldn't it be possible to do something like this?
> class MyClass
> def initialize
> @wm = Ruleby::Core::WorkingMemory.new
> load_rules
> end
> def load_rules
> @engine = Ruleby::Core::Engine.new(@wm)
> # ...Read your (possibly updated) rules here...
> @rules = MyRulebook.new(@engine).rules
> end
> end
> On Oct 28, 7:45 am, Jake Dempsey <angelo0...@gmail.com> wrote:
>> I am looking at ruleby as a two part module. The first piece I want to
>> use it for is the execution of a ruleset. The actual rules management
>> should be externalized in my case. In an environment where customers
>> drive the rules you want them to be able to change those rules without
>> the need of a deployment or a svn commit. I have been noodling how I
>> can use ruleby and remove the need for a larger implementation such as
>> drools.
>> The basic workflow I am after is:
>> Customer manages rules through a webui that persists their rules.
>> Ideally this would be done with a dsl specific to my application
>> domain and I have not yet figured out how best to approach this. I
>> really would like a grammar for my customer that generates ruleby
>> syntax. My app would start with a constant rule engine and empty
>> rulebook. On startup the persisted rules would be loaded. At some
>> point, either event based or time based, I would want to clear the
>> current rules and reload them. (this is because the customer may have
>> modified, added, or removed a rule). I dont want to have to create a
>> new engine (which blows away my working memory). Ideally I would have
>> a method .reset_rules on my rulebook that would remove all existing
>> rules and then calls .rules. This would allow me to keep a single
>> engine/rulebook and use my rule engine as a webservice where my users
>> can assert and retract facts at any point and each assert doesnt
>> create the need to create a new engine and reload all the rules.
>> Hope that explains what I'm after.
>> On Oct 27, 8:40 pm, Joe Kutner <jpkut...@gmail.com> wrote:
>> > These are both very interesting ways of building your rule base.
>> > While they seem to work for the two of you, they make me feel like the
>> > Rulebook design is lacking something. I would greatly welcome your
>> > suggestions on how to improve it for these kinds of cases.
>> > The assert_rule method take a Rule object as a parameter. The Rule
>> > class is not complicated, and the DSL simply builds one of these up
>> > behind the scenes. You can see an example of this around line 130 in
>> > ferrari.rb
>> > Joe
>> > On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
>> > > I am doing something similar, I have the rules written in a code field in an
>> > > events table in rails.
>> > > @event = Event.find_by_title(f)
>> > > engine :engine do |e|
>> > > TestRulebook.class_eval "def rules;" + @event.code + ";end;"
>> > > TestRulebook.new(e).rules
>> > > ...etc
>> > > While I was reading the doc recently I did notice a method which may be a
>> > > better way to go for this,
>> > > but I have not got around to figuring out how to do it.:
>> > > assert_rule(rule)
>> > > This method is invoked when a new rule is added to the system. The rule is
>> > > processed and the appropriate nodes are added to the network.
>> > > - Ric
>> > > On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
>> > > Ok i put the eval in the actual SampleRulebook class...i think i like
>> > > this better because the client accessing the rules doesnt know where
>> > > the rules are defined...which i like. So now I have:
I just wondered if this approach might help Jake retain his working
memory between reloads, or if there's some pitfall there. I saw
something in the source about needing to iterate over all facts when
new rules are added (the compare_to_wm method). Would that come into
play with a large set of facts?
On Nov 13, 10:44 am, Joe Kutner <jpkut...@gmail.com> wrote:
> That should be fine. The only reason we have the Ruleby::engine
> function is for convenience. And its probably only convenient for the
> tests :)
> If you have any suggestions for other idioms that make instantiating
> the engine easier, I'd be happy to work them into the sources.
> On Fri, Nov 13, 2009 at 9:34 AM, jhc <placidpun...@gmail.com> wrote:
> > I'm just starting to play around with Ruleby, so I may be off here.
> > But wouldn't it be possible to do something like this?
> > class MyClass
> > def initialize
> > @wm = Ruleby::Core::WorkingMemory.new
> > load_rules
> > end
> > def load_rules
> > @engine = Ruleby::Core::Engine.new(@wm)
> > # ...Read your (possibly updated) rules here...
> > @rules = MyRulebook.new(@engine).rules
> > end
> > end
> > On Oct 28, 7:45 am, Jake Dempsey <angelo0...@gmail.com> wrote:
> >> I am looking at ruleby as a two part module. The first piece I want to
> >> use it for is the execution of a ruleset. The actual rules management
> >> should be externalized in my case. In an environment where customers
> >> drive the rules you want them to be able to change those rules without
> >> the need of a deployment or a svn commit. I have been noodling how I
> >> can use ruleby and remove the need for a larger implementation such as
> >> drools.
> >> The basic workflow I am after is:
> >> Customer manages rules through a webui that persists their rules.
> >> Ideally this would be done with a dsl specific to my application
> >> domain and I have not yet figured out how best to approach this. I
> >> really would like a grammar for my customer that generates ruleby
> >> syntax. My app would start with a constant rule engine and empty
> >> rulebook. On startup the persisted rules would be loaded. At some
> >> point, either event based or time based, I would want to clear the
> >> current rules and reload them. (this is because the customer may have
> >> modified, added, or removed a rule). I dont want to have to create a
> >> new engine (which blows away my working memory). Ideally I would have
> >> a method .reset_rules on my rulebook that would remove all existing
> >> rules and then calls .rules. This would allow me to keep a single
> >> engine/rulebook and use my rule engine as a webservice where my users
> >> can assert and retract facts at any point and each assert doesnt
> >> create the need to create a new engine and reload all the rules.
> >> Hope that explains what I'm after.
> >> On Oct 27, 8:40 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> >> > These are both very interesting ways of building your rule base.
> >> > While they seem to work for the two of you, they make me feel like the
> >> > Rulebook design is lacking something. I would greatly welcome your
> >> > suggestions on how to improve it for these kinds of cases.
> >> > The assert_rule method take a Rule object as a parameter. The Rule
> >> > class is not complicated, and the DSL simply builds one of these up
> >> > behind the scenes. You can see an example of this around line 130 in
> >> > ferrari.rb
> >> > Joe
> >> > On Mon, Oct 26, 2009 at 2:17 PM, Richard Pruss <boa...@gmail.com> wrote:
> >> > > I am doing something similar, I have the rules written in a code field in an
> >> > > events table in rails.
> >> > > @event = Event.find_by_title(f)
> >> > > engine :engine do |e|
> >> > > TestRulebook.class_eval "def rules;" + @event.code + ";end;"
> >> > > TestRulebook.new(e).rules
> >> > > ...etc
> >> > > While I was reading the doc recently I did notice a method which may be a
> >> > > better way to go for this,
> >> > > but I have not got around to figuring out how to do it.:
> >> > > assert_rule(rule)
> >> > > This method is invoked when a new rule is added to the system. The rule is
> >> > > processed and the appropriate nodes are added to the network.
> >> > > - Ric
> >> > > On 27/10/2009, at 3:23 AM, Jake Dempsey wrote:
> >> > > Ok i put the eval in the actual SampleRulebook class...i think i like
> >> > > this better because the client accessing the rules doesnt know where
> >> > > the rules are defined...which i like. So now I have: