Plain english to conditions in ror??

Hi All,        I wanna to do something like as: 1. Use will type plain English in text box like designation equals PM or designation = PM.

2.Then i have to save this rule in DB and i have to made some function to verify this rule.

3. My problem is that how to make if condition for following rule dynamically.Cos in ROR i can say designation == 'PM'then fine but how i will check that designation equals PM.

4.Means i have to make condition from plain english dynamically.

Please tell me ur suggestions.

Thanks Varun

I would recommend that you create a DSL for your users. You can setup a mapping that abstracts away your domain specific names and allows for various types of rule creation. You need to guard/filter against code injection if you are eval-ing the rules directly.

Hope that helps.

Take a look at TreeTop. I'm not sure how complicated you want to get, but it might be what you are looking for. http://www.rubyinside.com/treetop-powerful-but-easy-ruby-parser-library-701.html

HTH