Module: Ruleby::RuleHelper

Included in:
Rulebook
Defined in:
lib/rule_helper.rb

Instance Method Summary collapse

Instance Method Details

#__eval__(x) ⇒ Object



67
68
69
# File 'lib/rule_helper.rb', line 67

def __eval__(x)
  eval(x)
end

#AND(*args) ⇒ Object



63
64
65
# File 'lib/rule_helper.rb', line 63

def AND(*args)
  Ruleby::Ferrari::AndBuilder.new args
end

#b(variable_name) ⇒ Object



35
36
37
# File 'lib/rule_helper.rb', line 35

def b(variable_name)
  Ruleby::Ferrari::BindingBuilder.new(variable_name)
end

#c(&block) ⇒ Object



39
40
41
# File 'lib/rule_helper.rb', line 39

def c(&block)
  lambda(&block)
end

#f(args, block = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rule_helper.rb', line 43

def f(args, block=nil)
  if block.nil?
    if !args.is_a?(Proc)
      raise "You must provide a Proc!"
    else
      Ruleby::Ferrari::FunctionBuilder.new([], args)
    end
  else
    if args.is_a?(Array)
      Ruleby::Ferrari::FunctionBuilder.new(args, block)
    else
      Ruleby::Ferrari::FunctionBuilder.new([args], block)
    end
  end
end

#mObject



27
28
29
# File 'lib/rule_helper.rb', line 27

def m
  Ruleby::Ferrari::MethodBuilder.new
end

#methodObject



31
32
33
# File 'lib/rule_helper.rb', line 31

def method
  m
end

#OR(*args) ⇒ Object



59
60
61
# File 'lib/rule_helper.rb', line 59

def OR(*args)
  Ruleby::Ferrari::OrBuilder.new args
end

#rule(*args, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/rule_helper.rb', line 16

def rule(*args, &block) 
  name = nil
  unless args.empty?
    name = args[0].kind_of?(Symbol) ? args.shift : GeneratedTag.new
  end
  options = args[0].kind_of?(Hash) ? args.shift : {}        

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