Module: Spider::Model::ConditionMixin
- Included in:
- ConditionContext, ConditionElement, ConditionElementCreator
- Defined in:
- lib/spiderfw/model/condition.rb
Overview
Helper module used for Condition block syntax
Defined Under Namespace
Classes: ConditionElement, ConditionElementCreator
Instance Method Summary collapse
- #__create_condition_element(meth) ⇒ Object
-
#__el(meth) ⇒ Object
:nodoc:.
- #AND(&proc) ⇒ Object
- #id ⇒ Object
- #method_missing(meth, *arguments) ⇒ Object
- #OR(&proc) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *arguments) ⇒ Object
487 488 489 |
# File 'lib/spiderfw/model/condition.rb', line 487 def method_missing(meth, *arguments) __create_condition_element(meth) end |
Instance Method Details
#__create_condition_element(meth) ⇒ Object
491 492 493 494 495 496 497 498 499 500 |
# File 'lib/spiderfw/model/condition.rb', line 491 def __create_condition_element(meth) if (meth == :q) return ConditionElementCreator.new end if (meth.to_s =~ /element_(.+)/) # alternative syntax to avoid clashes 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
:nodoc:
483 484 485 |
# File 'lib/spiderfw/model/condition.rb', line 483 def __el(meth) __create_condition_element(meth) end |
#AND(&proc) ⇒ Object
506 507 508 509 510 511 512 513 514 515 |
# File 'lib/spiderfw/model/condition.rb', line 506 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 |
#id ⇒ Object
502 503 504 |
# File 'lib/spiderfw/model/condition.rb', line 502 def id return ConditionElement.new(:id, @condition_context) end |