one of retractor obj to cool obj. If you have 3 CoolObjs in working
> Ruleby does not support retracting rules at this time.
> In your case, I think you would be better served by creating a new
> class that you can write rules for retracting facts around. Something
> like this:
> class Retractor
> attr :class_to_retract
> end
> rule [CoolObj, :c, m.pk == params[:pk], m.type == params[:type]],
> [Retractor, :r, m.class_to_retract = CoolObj] do |v|
> retract(v[:c])
> retract(v[:r])
> end
> The Retractor class could even contain the patterns you use to select
> the CoolObjs. I hope this helps, please let me know if its not clear.
> Joe
> On Tue, Oct 27, 2009 at 3:21 PM, Jake Dempsey <angelo0...@gmail.com> wrote:
> > Is there a way to remove a rule from the rulebase at runtime?
> > I want to create a rules engine that is exposed as a webservice.
> > Clients will post to /facts/assert to put a new fact into the working
> > memory and will post to /facts/retract to remove a fact from the
> > working memory. I currently start my environment by creating a single
> > engine and single rulebook:
> > //happens on start:
> > RULER_ENGINE = Ruleby::Core::Engine.new
> > RULE_BOOK = SimpleRulebook.new(RULER_ENGINE)
> > RULE_BOOK.rules //loads rules from external source
> > In my facts controller I have something like this:
> > def assert
> > RULER_ENGINE.assert CoolObj.new(params[:obj])
> > RULER_ENGINE.match
> > render :nothing => true
> > end
> > def retract
> > GarbageManRules.new(RULER_ENGINE) do |rb|
> > rb.rule [CoolObj, :c, m.pk == params[:pk], m.type == params
> > [:type]] do |v|
> > rb.retract(v[:c])
> > end
> > end
> > RULER_ENGINE.match
> > render :nothing => true
> > end
> > My understanding is that when I add the rule to the rulebase..its
> > there forever. In my case its really a transient rule just used to
> > remove something from the working memory and should be removed after
> > that action. Am I maybe approaching this wrong? Is there a way to
> > remove this rule from the rulebase once I am done with it?