question <rails-mailing-list@...> writes:
Hi, i was wondering whether there was a better way to write something in this type of format:
def foo if x somefunction ..find(:all, :conditions => a + b + c + d) else samefunction ..find(:all, :conditions => a + b + c) end end
into something a lot shorter like:
def foo somefunction find(:all, :condtions => a + b + c, :with_exclusive_scope?? => d ) end
I wrote a class a couple of days ago for just this kind of thing:
use it like:
def foo conditions = Conditions.new conditions << ["a = ?", a] conditions << ["b = ?", b] conditions << ["c = ?", c] conditions << ["d = ?", d] if x
find(:all, :conditions => conditions) end
Gareth