Module: Ruleby::Ferrari
- Defined in:
- lib/dsl/ferrari.rb
Defined Under Namespace
Classes: AndBuilder, AtomBuilder, BindingBuilder, Container, FunctionBuilder, MethodBuilder, NotOperatorBuilder, OrBuilder, PatternContainer, RuleBuilder, RulebookHelper, RulesContainer
Class Method Summary collapse
Class Method Details
.parse_containers(args, container = Container(:and), parent = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dsl/ferrari.rb', line 31 def self.parse_containers(args, container=Container(:and), parent=nil) con = nil if(container.kind_of?(RulesContainer)) con = Container.new(:and) else con = container end args.each do |arg| if arg.kind_of? Array con << PatternContainer.new(arg) elsif arg.kind_of? AndBuilder con << parse_containers(arg.conditions, Container.new(:and), container) elsif arg.kind_of? OrBuilder con << parse_containers(arg.conditions, Container.new(:or), container) else raise 'Invalid condition. Must be an OR, AND or an Array.' end end if container.kind_of?(RulesContainer) container << con end return container end |