Can't get 0.3 to work

2 views
Skip to first unread message

gmcinnes

unread,
Jul 24, 2007, 4:43:03 PM7/24/07
to Rools-dev
Hi Pat:

Great package with lots of potential, but I can't get 0.3 to work
properly. I'm having the same issues as described in bug #11965

I tried going back to 0.1.5 with require_gem 'rools', '=0.1.5' and
things seem to work properly there, but some of the nice functionality
like extends is missing, so it's not as useful to me.

I'd be happy to help debug if you can get back to me with where to
start.

The only thing that springs to mind here is that I"m passing an
ActiveRecord object in on the block, and AR makes extensive use of
method_missing, so maybe things are getting stomped upon?

Let me know if you have any ideas.

Pat Cappelaere

unread,
Jul 24, 2007, 5:06:06 PM7/24/07
to rool...@googlegroups.com
Hi Grant,

Would love to help but you might need to give me more details here.
bug #11965 is due to a typo. The error has been cleaned in 0.3 (still get
an error though).

You may want to try to give me a test case and full output in debug mode.
V/R,
Pat.

gmcinnes

unread,
Jul 25, 2007, 10:31:10 AM7/25/07
to Rools-dev
Hi Pat:

I have lots of questions. I think probably most of what's going on
here is that I don't understand how rules engines work - this is my
first attempt. I have no context from other systems. If we can work
on this, I can write things up from a newb perspective, and hopefully
this can help someone else.

I pasted my code at http://pastie.caboo.se/82094

As you can see, I'm using rspec to drive the development.

>From the output you can see that the 'patient' fact is being created.
I was under the impression that I could refer to the patient fact by
any underscored_variable_name, but I seem only to be able to refer to
it by the lower case name of the class that is asserted in the
parameter. Is that right?

Questions:

- How do I refer to more than one parameter of the same class if I
need to compare two Patient's in the rule.
- How do I add something to the set of facts outside of a rule?
Several of my rules rely on a 'last_two_weeks' hash which looks like
{:from => 2.weeks.ago, :to => today}. This hash is stored in a
module, and I want to make it available to the rules.
- How can I return the status of what rule(s) passes to to the
calling method?

Total newb. I've looked around on the docs and I don't see any
answers to the above. If they are there, I apologize - please point
me in their direction :)

Thanks again,
-grant


On Jul 24, 5:06 pm, Pat Cappelaere <cappela...@gmail.com> wrote:
> Hi Grant,
>
> Would love to help but you might need to give me more details here.
> bug #11965 is due to a typo. The error has been cleaned in 0.3 (still get
> an error though).
>
> You may want to try to give me a test case and full output in debug mode.
> V/R,
> Pat.
>

Pat Cappelaere

unread,
Jul 25, 2007, 2:27:04 PM7/25/07
to rool...@googlegroups.com
Grant,

Great job about rspec!

I think we need to break this list of questions down a bit to avoid too much
confusion and lengthy responses...

Your defined rule is ready to trigger every time a "Patient" fact is
asserted. The convention is to use the lowercase name as a variable in the
condition. This is being enforced now to support multiple triggers.

I am not sure you would write a generic rule to access to compare two
specific patients unless the patients are of different types. In that case
you could have:
rule 'two week high blood pressure' do
parameter Patient1
parameter Patient2
condition { patient1.xxx ... patient2.yyy ... }
end

Otherwise you can still refer to specific patients if they are accessible in
your Ruby environment (like global variables: $patient1 $patient2... )

> - How do I add something to the set of facts outside of a rule?

You should be able to add facts to a ruleset. In your case
Rules.fact( )

> Several of my rules rely on a 'last_two_weeks' hash which looks like
> {:from => 2.weeks.ago, :to => today}. This hash is stored in a
> module, and I want to make it available to the rules.

If it is available to your global ruby environment, it ought to be available
to Rools. Have tried to use a global variable to store your hash?

> - How can I return the status of what rule(s) passes to to the
> calling method?

Actually, I do a lot of that for testing. You can do anything you want
within the consequence block - like set a variable, send a message...

V/R,
Pat.

> From: gmcinnes <grant....@eyesopen.ca>
> Reply-To: <rool...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages