Class: Ruleby::Ferrari::RulebookHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/ferrari.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ RulebookHelper

Returns a new instance of RulebookHelper.



15
16
17
# File 'lib/dsl/ferrari.rb', line 15

def initialize(engine)
  @engine = engine
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



19
20
21
# File 'lib/dsl/ferrari.rb', line 19

def engine
  @engine
end

Instance Method Details

#rule(name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/dsl/ferrari.rb', line 21

def rule(name, *args, &block) 
  options = args[0].kind_of?(Hash) ? args.shift : {}        

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