DSL conditional syntax rules

9 views
Skip to first unread message

jason

unread,
Oct 4, 2009, 10:34:16 AM10/4/09
to Ruleby
dear groupies,

are the following DSL conditional syntax rules correct?

1. Direct comparison of m.methods not possible:

i.e. m.foo > m.bar

therefore this will not work.

[ExistingAction, :action, m.aspirin_strength >
m.pain_threshold] do |v|
puts "relief"
end

2. Direct comparison of bindings not possible:

i.e b(:foo) > b(:bar)

therefore this will not work.

[ExistingAction, :action, {m.aspirin_strength=> :a_s,
m.pain_threshold => :p_t}, b(:a_s) > b(p_t)] do |v|
puts "relief"
end

3. Direct comparison between m.method with Strings, Fixnum and Sym

i.e. m.size > 20
i.e. m.message == "hello"
i.e. m.staus == :happy

therefore this will work

[ExistingAction, :action, m.aspirin_strength > 20, m.feeling ==
"awful", m.status == :unhappy] do |v|
puts "relief"
end

4 Indirect comparison of m.methods through binding on right hand side

i.e. {m.foo => :foo}, m.bar == b(:foo)

therefore this will work

[ExistingAction, :action, {m.aspirin_strength => :a_s},
m.pain_threshold > b(:a_s)] do |v|
puts "no relief"
end

Is this correct - am i missing something?

thanks a million for feedback

jason.




Joe Kutner

unread,
Oct 4, 2009, 2:50:05 PM10/4/09
to rul...@googlegroups.com
You are correct on all four counts.

Adding the behavior you describe in #1 and #2 is certainly possible.
It would be a good starting point for someone that is interested in
contributing to the project.

jason

unread,
Oct 4, 2009, 5:44:13 PM10/4/09
to Ruleby
Ok great to know.

I think that ruleby is totally fantastic actually (I think it actually
just saved my arse) - even if it is a pain to get into it - this is
primarily a problem with the documentation. (Ahh you are the joe on
the video http://rubyhoedown2008.confreaks.com/10-joe-kutner-ruleby-the-rule-engine-for-ruby.html
- excellent presentation by the way - you (someone) really needs to
get that on to the ruleby wiki - it really is almost a prerequisite
for understanding ruleby (much better) - regardless of CS background
or not.

I think adding the functionality described in #1 and #2 is the sugar
on top of the documentation that makes ruleby behave more like you
would expect it to - and would make the code very much more readable.

I also think that if anyone should spend time sugaring in up then to
bring it up more on the lines of Rspec, Mocha and ActiveRecord - I
think that this might open up the project to a much wider audience.

Users could then write stuff like:


describe_rules_for "some rule book" do

it "should do some magic stuff" do
given a_kind_of SomeClass with(conditions => {:aaa => bbb}) do
puts "some finky stuff"
end
end

end
end

anyway i guess you get my gist.

If you need any help on the wiki doc i would be more than willing to
punch my learnings into it as a newby after one weekend. I integrated
a fully functional rule book for moving nodes around a tree - and I am
fairly happy with the code now.

I would be more than happy to help coding - just at the moment I am
very late with this project - considering that ruleby is now part of
it - this would warrent investing time in the code. (some time at the
beginning of next year I expect).

Thanks again for a great project
Jason.



On Oct 4, 8:50 pm, Joe Kutner <jpkut...@gmail.com> wrote:
> You are correct on all four counts.
>
> Adding the behavior you describe in #1 and #2 is certainly possible.
> It would be a good starting point for someone that is interested in
> contributing to the project.
>

Joe Kutner

unread,
Oct 6, 2009, 12:35:22 PM10/6/09
to Ruleby
FYI I added the feature described in #1 to the trunk. In doing so, I
decided that #2 really wasn't necessary.

On Oct 4, 4:44 pm, jason <jason.franklin.sto...@gmail.com> wrote:
> Ok great to know.
>
> I think that ruleby is totally fantastic actually (I think it actually
> just saved my arse) - even if it is a pain to get into it - this is
> primarily a problem with the documentation. (Ahh you are the joe on
> the videohttp://rubyhoedown2008.confreaks.com/10-joe-kutner-ruleby-the-rule-en...

jason franklin-stokes

unread,
Oct 6, 2009, 1:53:04 PM10/6/09
to rul...@googlegroups.com
Joe, that's excellent - I will give that a run today - this feature will simply my code a great deal.
thanks a million.
Jason.
Reply all
Reply to author
Forward
0 new messages