In my effort for porting the geokit-rails plugin to Rails 3, I've found that it would really benefit a full rewrite of the query composition parts.
My work can be followed here : http://github.com/jlecour/geokit-rails/ (make sure to look at the gem branch until it is merged into master) Any help is welcome.
The current version, compatible with Rails 2, has 2 main methods (find
and count
) and some utility methods, that are making some changes to the select/conditions/limit/order/… parts of the options hash passed to ActiveRecord and then call the super
related method on the model's class.
With ActiveRecord 3 and its scope approche, I think we don't need to mess with the hash anymore if we use the power of scopes. I would be cleaner, more chainable and reusable, …
That said, we have to consider the kind of additions Geokit makes to a typical query. As a brief summary, here is how it works.