condition_builder
ConditionBuilder generates conditions and criteria for use in ActiveRecord .find statements to avoid manually having to construct a string of conditions and the releveant hash with values.
It does not support fancy dependencies between the statements as it would make the syntax so complicated that people might as well generate the condition string and hash themselves.
Usage
cb = ConditionBuilder.new
# add a condition "user_id < 4" in descending order
cb.add('user_id <', 4, :desc)
# add a condition "user_location like '%abc'" in ascending order
cb.add('user_location like', '%abc', :asc)
# add a condition "department_id = 18"
cb.add('department_id = ', 18)
User.find(:all, :conditions => cb.conditions, :order => cb.order, cb.criteria)
Website
github.com/peterhoeg/condition_builder
Requirements
ConditionBuilder has been tested with the following versions
Ruby
-
1.8.7
Copyright
Copyright © 2009 Peter Hoeg. See LICENSE for details.