Class: Lafcadio::Query::Condition
- Inherits:
-
Object
- Object
- Lafcadio::Query::Condition
show all
- Defined in:
- lib/lafcadio/query.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(fieldName, searchTerm, domain_class) ⇒ Condition
Returns a new instance of Condition.
358
359
360
361
362
363
364
365
366
367
|
# File 'lib/lafcadio/query.rb', line 358
def initialize(fieldName, searchTerm, domain_class)
@fieldName, @searchTerm, @domain_class =
fieldName, searchTerm, domain_class
unless @searchTerm.is_a?( self.class.search_term_type )
raise "Incorrect searchTerm type #{ searchTerm.class }"
end
if @domain_class and !( @domain_class < DomainObject )
raise "Incorrect object type #{ @domain_class.to_s }"
end
end
|
Instance Attribute Details
#domain_class ⇒ Object
Returns the value of attribute domain_class.
356
357
358
|
# File 'lib/lafcadio/query.rb', line 356
def domain_class
@domain_class
end
|
Class Method Details
.search_term_type ⇒ Object
352
353
354
|
# File 'lib/lafcadio/query.rb', line 352
def Condition.search_term_type
Object
end
|
Instance Method Details
#&(other_cond) ⇒ Object
371
|
# File 'lib/lafcadio/query.rb', line 371
def &( other_cond ); Query.And( self, other_cond ); end
|
#db_field_name ⇒ Object
380
|
# File 'lib/lafcadio/query.rb', line 380
def db_field_name; field.db_column; end
|
#eql?(other_cond) ⇒ Boolean
382
383
384
|
# File 'lib/lafcadio/query.rb', line 382
def eql?( other_cond )
other_cond.is_a?( Condition ) and other_cond.to_sql == to_sql
end
|
#field ⇒ Object
386
387
388
389
390
391
392
393
394
|
# File 'lib/lafcadio/query.rb', line 386
def field
f = @domain_class.field @fieldName.to_s
f or raise(
MissingError,
"Couldn't find field \"#{ @fieldName }\" in " + @domain_class.name +
" domain class",
caller
)
end
|
#implies?(other_condition) ⇒ Boolean
373
374
375
376
377
378
|
# File 'lib/lafcadio/query.rb', line 373
def implies?( other_condition )
self.eql?( other_condition ) or (
other_condition.respond_to?( :implied_by? ) and
other_condition.implied_by?( self )
)
end
|
#not ⇒ Object
396
|
# File 'lib/lafcadio/query.rb', line 396
def not; Query::Not.new( self ); end
|
#one_pk_id? ⇒ Boolean
398
|
# File 'lib/lafcadio/query.rb', line 398
def one_pk_id?; self.is_a?( Equals ) and primary_key_field?; end
|
#primary_key_field? ⇒ Boolean
400
|
# File 'lib/lafcadio/query.rb', line 400
def primary_key_field?; 'pk_id' == @fieldName; end
|
#query ⇒ Object
402
|
# File 'lib/lafcadio/query.rb', line 402
def query; Query.new( @domain_class, :condition => self ); end
|
#to_condition ⇒ Object
404
|
# File 'lib/lafcadio/query.rb', line 404
def to_condition; self; end
|
#|(other_cond) ⇒ Object
369
|
# File 'lib/lafcadio/query.rb', line 369
def |( other_cond ); Query.Or( self, other_cond ); end
|