From: Caleb Clausen Date: 2006-07-24T11:12:20+09:00 Subject: Re: Mongoose 0.2.0 On 7/23/06, Jamey Cribbs wrote: > No, it looks like I will have to go back to doing a yield in Table.find, > which means the user is going to have to specify a block parameter in > the #find block. In other words: > > Employee.find { |emp| emp.dept == @dept } > > I guess it doesn't look that bad. Ok, this is a totally different sort of query language, but have you considered something like Reg? (http://rubyforge.org/projects/reg/ or gem install reg) I took a more declarative approach (at least, I think so) to a query languange, which (IMNSHO) is a better fit with the problem. Reg is entirely based off #===, so all you'd need to do is allow your find to take a parameter which responds to #===. That would make the above example look like: Employee.find(item_that.dept==@dept) or alternately: Employee.find(-{:dept=>@dept}) This should solve your problem with instance variable visibility in blocks, since there are no blocks, but does it create other problems? I don't know. Reg is entirely designed from the point of view of queries on in-memory Ruby object trees, so that's a little different than a database model. But maybe you can get some ideas if nothing else... I don't know anything about skiplists or database query optimization, but Reg expressions look like nicely parsed trees of objects, so that ought to be something you can work with...