Class: OrWhereBuilder
- Inherits:
-
WhereBuilder
- Object
- WhereBuilder
- OrWhereBuilder
- Defined in:
- lib/or_where_builder.rb
Instance Attribute Summary
Attributes inherited from WhereBuilder
Instance Method Summary collapse
-
#to_sql ⇒ Object
call-seq: or_where.to_sql -> a_string.
Methods inherited from WhereBuilder
#add_clause, #add_condition, #add_parenthesis_condition, #equal, #exists, #greater_than, #greater_than_or_equal, #initialize, #is_in, #is_not_in, #is_not_null, #less_than, #less_than_or_equal, #like, #not_equal, #not_exists
Constructor Details
This class inherits a constructor from WhereBuilder
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class WhereBuilder
Instance Method Details
#to_sql ⇒ Object
call-seq: or_where.to_sql -> a_string
Returns a string by collecting all the conditions and joins them with ‘ and ’.
OrWhereBuilder.new [] do
equal :column1, 10
equal :column2, 'book'
end.to_sql #=> " or (column1 = 10 and column2 = 'book')"
11 12 13 |
# File 'lib/or_where_builder.rb', line 11 def to_sql " or (#{sql_parts.join(' and ')})" end |