Rulebooks as Decorators for Engine

8 views
Skip to first unread message

Richard Pruss

unread,
Dec 7, 2009, 7:55:56 AM12/7/09
to rul...@googlegroups.com
Hi Joe,

I am looking for a decent idiom for dynamically defining the rules from 
multiple classes into the enginer.

Here is a problem definition, to see if I am even thinking along the right line.

I have a engine into which I assert a data feed - of current prices.

I assert strategies into the engine as facts and I use rules based on price
and strategy object data to to take actions, which are mainly methods in said
strategies.

All pretty neat except for how I load rule, currently rules are loaded as I
mentioned before as eval statements in a common rulebook.

More contained and testable would be to have the def rules in the strategy.

Then I could do something like

engine :engine do |e|
  strat1 = StratergyOne.new(lots of fields)
  strat2 = StratergyOne.new(lots of fields)
strat3 = StratergyTwo.new(lots of fields)

  e.assert strat1
e.assert strat2
e.assert strat3

# the hope is that these would assert the ferrari rules from the strategies to the engine
strat1.rules
strat2.rules
strat3.rules

loop for price assert and match
  e.match

etc

- Ric

Matt Smith

unread,
Dec 7, 2009, 9:36:50 AM12/7/09
to rul...@googlegroups.com
Hi Ric,

Does passing the engine into the rules method help to solve your problem?

strat1.rules(e)

and then use the engine to create the CommonRulebook and rules from there.

Matt

--

You received this message because you are subscribed to the Google Groups "Ruleby" group.
To post to this group, send email to rul...@googlegroups.com.
To unsubscribe from this group, send email to ruleby+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ruleby?hl=en.

Richard Pruss

unread,
Dec 7, 2009, 5:22:17 PM12/7/09
to rul...@googlegroups.com
I have not quiet got to the stage where I have a problem.  Just playing with
ideas for the design before I start to refractor it.

I was thinking of passing the engine in the initialise but you right in the rule method is
better contained.

- Ric
Reply all
Reply to author
Forward
0 new messages