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
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_(.+)/) # 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:
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 |
#id ⇒ Object
504 505 506 |
# File 'lib/spiderfw/model/condition.rb', line 504 def id return ConditionElement.new(:id, @condition_context) end |