Class: OrWhereBuilder

Inherits:
WhereBuilder show all
Defined in:
lib/or_where_builder.rb

Instance Attribute Summary

Attributes inherited from WhereBuilder

#tables

Instance Method Summary collapse

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_sqlObject

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