Ambition is nice.
Pros:
1. Kicker methods: makes easier to do caching
2. Chain methods: User.select(...).sort_by(...).first(5)
Cons:
1. It should accept more stuff than just Blocks.
The select method, for example, could accept:
+ Proc
User.select { (:name == "Bob" || :name == "Joe") && :age >= 21 }.
+ String (obviously)
User.select "(name = 'Bob' OR name = 'Joe') AND age >= 21"
+ Arrays (as rails)
User.select ["(name = ? OR name = ?) AND age >= ?",'Bob','Joe',21]
+ Hash (with just some of the datamapper magic)
User.select {:name => 'Bob', :name => 'Joe'}
Is important to give options mainly because of performance:
http://groups.google.com/group/sequel-talk/browse_thread/thread/9da17d7c9fbd48ea
In the 4th message there is a benchmark done by Sharon Rosner and
we see that the Proc stuff is really slow.
Another pro is that DataMapper can totally adapt itself into Ambition.
So it can provide a find method with chain and kicker functionality:
User.find(:where => ["(name = ? OR name = ?) AND age >= ?",'Bob','Joe',
21], :order_by => "age DESC").first(5)
This is nice because find, select and sort_by methods would just
change a Hash Object. Then we could do things like this:
class Articles < Datamapper
def recent
self.find(:order_by => 'created_at DESC')
end
def published
self.select(:published => true)
end
end
Articles.published.recent.first(5)
The Hash Object is processed only when the kicker methods are called.