Class: Lafcadio::Query::Equals
- Defined in:
- lib/lafcadio/query/Equals.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Condition
Instance Method Summary collapse
Methods inherited from Condition
#dbFieldName, #getField, #initialize, #not, #primaryKeyField?, searchTermType
Constructor Details
This class inherits a constructor from Lafcadio::Query::Condition
Instance Method Details
#objectMeets(anObj) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lafcadio/query/Equals.rb', line 29 def objectMeets(anObj) if @fieldName == @objectType.sqlPrimaryKeyName object_value = anObj.pkId else object_value = anObj.send @fieldName end compare_value = if @searchTerm.class <= ObjectField compare_value = anObj.send( @searchTerm.name ) else compare_value = @searchTerm end compare_value == object_value end |
#r_val_string ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lafcadio/query/Equals.rb', line 16 def r_val_string if primaryKeyField? @searchTerm.to_s else field = getField if @searchTerm.class <= ObjectField @searchTerm.db_table_and_field_name else field.valueForSQL(@searchTerm).to_s end end end |
#toSql ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/lafcadio/query/Equals.rb', line 6 def toSql sql = "#{ dbFieldName } " unless @searchTerm.nil? sql += "= " + r_val_string else sql += "is null" end sql end |