/sql_condition_builder

Build AR condition hashes dynamically

Primary LanguageRubyMIT LicenseMIT

SqlConditionBuilder
===================

Build AR conditions easily.


Example
=======

builder = SqlConditionBuilder.new

@builder.add_condition "foo IS NULL"
@builder.add_condition "(bar = ? OR bar = ?)", 10, 20
@builder.baz = "something"

@builder.to_a    #=> ["foo IS NULL AND (bar = ? OR bar = ?) AND baz = ?", 10, 20, "something"]
@builder.to_sql  #=> "foo IS NULL AND (bar = 10 OR bar = 20) AND baz = 'something'"



Copyright (c) 2009 Scott Taylor / smtlaissezfaire <scott@railsnewbie.com>, released under the MIT license