Class: AndWhereBuilder

Inherits:
WhereBuilder show all
Defined in:
lib/and_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: and_where.to_sql -> a_string

Returns a string by collecting all the conditions and joins them with ‘ and ’.

AndWhereBuilder.new [] do 
  equal :column1, 10
  equal :column2, 'book'
end.to_sql         #=> " and (column1 = 10 and column2 = 'book')"


10
11
12
# File 'lib/and_where_builder.rb', line 10

def to_sql
  " and (#{sql_parts.join(' and ')})"
end