Method: OrientSupport::OrientQuery#target

Defined in:
lib/support/orientquery.rb

#target(arg = nil) ⇒ Object



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/support/orientquery.rb', line 416

def target arg =  nil
	if arg.present?
		@q[:database] =  arg
		self # return query-object
	elsif @q[:database].present? 
		the_argument =  @q[:database]
		case @q[:database]
							when ActiveOrient::Model   # a single record
								the_argument.rrid
							when self.class	      # result of a query
								' ( '+ the_argument.compose + ' ) '
							when Class
								the_argument.ref_name
							else
								if the_argument.to_s.rid?	  # a string with "#ab:cd"
									the_argument
								else		  # a database-class-name
									the_argument.to_s  
								end
							end
	else
		raise "cannot complete until a target is specified"
	end
end