Class: Lafcadio::Query::Equals

Inherits:
Condition show all
Defined in:
lib/lafcadio/query.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Condition

#domain_class

Instance Method Summary collapse

Methods inherited from Condition

#&, #db_field_name, #eql?, #field, #implies?, #initialize, #not, #one_pk_id?, #primary_key_field?, #query, search_term_type, #to_condition, #|

Constructor Details

This class inherits a constructor from Lafcadio::Query::Condition

Instance Method Details

#dobj_satisfies?(anObj) ⇒ Boolean

Returns:

  • (Boolean)


533
534
535
536
537
538
539
540
# File 'lib/lafcadio/query.rb', line 533

def dobj_satisfies?(anObj)
	if @searchTerm.is_a?( ObjectField )
		compare_value = anObj.send @searchTerm.name
	else
		compare_value = @searchTerm
	end
	compare_value == anObj.send( @fieldName )
end

#r_val_stringObject



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/lafcadio/query.rb', line 542

def r_val_string
	if @searchTerm.is_a?( ObjectField )
		@searchTerm.db_column
	else
		begin
			field.value_for_sql( @searchTerm ).to_s
		rescue DomainObjectInitError
			raise(
				ArgumentError,
				"Can't query using an uncommitted domain object as a search " +
						"term.",
				caller
			)
		end
	end
end

#to_sqlObject



559
560
561
562
563
# File 'lib/lafcadio/query.rb', line 559

def to_sql
	sql = "#{ db_field_name } "
	sql += ( !@searchTerm.nil? ? "= #{ r_val_string }" : "is null" )
	sql
end