Module: Spider::Model::ConditionMixin
Overview
Helper module used for Condition block syntax
Defined Under Namespace
Classes: ConditionElement, ConditionElementCreator
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *arguments) ⇒ Object
489
490
491
|
# File 'lib/spiderfw/model/condition.rb', line 489
def method_missing(meth, *arguments)
__create_condition_element(meth)
end
|
Instance Method Details
#__create_condition_element(meth) ⇒ Object
493
494
495
496
497
498
499
500
501
502
|
# File 'lib/spiderfw/model/condition.rb', line 493
def __create_condition_element(meth)
if (meth == :q)
return ConditionElementCreator.new
end
if (meth.to_s =~ /element_(.+)/)
meth = $1.to_sym
end
name = @condition_element_name ? "#{@condition_element_name}.#{meth}" : meth.to_s
return ConditionElement.new(name, @condition_context)
end
|
#__el(meth) ⇒ Object
485
486
487
|
# File 'lib/spiderfw/model/condition.rb', line 485
def __el(meth)
__create_condition_element(meth)
end
|
#AND(&proc) ⇒ Object
508
509
510
511
512
513
514
515
516
517
|
# File 'lib/spiderfw/model/condition.rb', line 508
def AND(&proc)
@condition_context = []
instance_eval(&proc)
c = Condition.and
@condition_context.each do |cond|
c << cond unless (cond.conjunct)
end
@condition_context = nil
return c
end
|
504
505
506
|
# File 'lib/spiderfw/model/condition.rb', line 504
def id
return ConditionElement.new(:id, @condition_context)
end
|
#OR(&proc) ⇒ Object
519
520
521
522
523
524
525
526
527
528
|
# File 'lib/spiderfw/model/condition.rb', line 519
def OR(&proc)
@condition_context = []
instance_eval(&proc)
c = Condition.and
@condition_context.each do |cond|
c << cond unless (cond.conjunct)
end
@condition_context = nil
return c
end
|