/
rule_helper.rb
56 lines (45 loc) · 1.16 KB
/
rule_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# This file is part of the Ruleby project (http://ruleby.org)
#
# This application is free software; you can redistribute it and/or
# modify it under the terms of the Ruby license defined in the
# LICENSE.txt file.
#
# Copyright (c) 2007 Joe Kutner and Matt Smith. All rights reserved.
#
# * Authors: Joe Kutner, Matt Smith
#
require 'core/engine'
module Ruleby
module RuleHelper
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
def m
Ruleby::Ferrari::MethodBuilder.new
end
def method
m
end
def b(variable_name)
Ruleby::Ferrari::BindingBuilder.new(variable_name)
end
def c(&block)
return lambda(&block)
end
def OR(*args)
Ruleby::Ferrari::OrBuilder.new args
end
def AND(*args)
Ruleby::Ferrari::AndBuilder.new args
end
def __eval__(x)
eval(x)
end
end
end