Skip to content

Commit

Permalink
fix broken OR, rule_helper returns array of rules
Browse files Browse the repository at this point in the history
  • Loading branch information
amattsmith committed Jul 13, 2010
1 parent 4a00eed commit ffd4369
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/dsl/ferrari.rb
Expand Up @@ -21,8 +21,10 @@ def initialize(engine)
def rule(name, *args, &block)
options = args[0].kind_of?(Hash) ? args.shift : {}

r = Ruleby::Ferrari.parse_containers(args, RulesContainer.new).build(name,options,@engine,&block)
engine.assert_rule(r)
rules = Ruleby::Ferrari.parse_containers(args, RulesContainer.new).build(name,options,@engine,&block)
rules.each do |r|
engine.assert_rule(r)
end
end
end

Expand Down Expand Up @@ -69,14 +71,16 @@ def self.parse_containers(args, container=AndContainer.new)

class RulesContainer < Array
def build(name,options,engine,&block)
rules = []
self.each do |x|
r = RuleBuilder.new name
x.build r
r.then(&block)
r.priority = options[:priority] if options[:priority]
#engine.assert_rule(r.build_rule)
return r.build_rule
rules << r.build_rule
end
return rules
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rule_helper.rb
Expand Up @@ -20,8 +20,8 @@ def rule(*args, &block)
end
options = args[0].kind_of?(Hash) ? args.shift : {}

r = Ruleby::Ferrari.parse_containers(args, Ruleby::Ferrari::RulesContainer.new).build(name,options,@engine,&block)
r
rules = Ruleby::Ferrari.parse_containers(args, Ruleby::Ferrari::RulesContainer.new).build(name,options,@engine,&block)
rules
end

def m
Expand Down

0 comments on commit ffd4369

Please sign in to comment.