-
Notifications
You must be signed in to change notification settings - Fork 5
/
flow_api.rb
56 lines (50 loc) · 1.53 KB
/
flow_api.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
module ATP
module FlowAPI
def atp=(atp)
@atp = atp
end
def atp
@atp
end
([:test, :bin, :pass, :continue, :cz, :log, :sub_test, :volatile, :set_flag, :set, :enable, :disable, :render,
:context_changed?, :ids, :describe_bin, :describe_softbin, :describe_soft_bin, :loop] +
ATP::Flow::CONDITION_KEYS.keys + ATP::Flow::RELATIONAL_OPERATORS).each do |method|
define_method method do |*args, &block|
options = args.pop if args.last.is_a?(Hash)
options ||= {}
add_meta!(options) if respond_to?(:add_meta!, true)
add_description!(options) if respond_to?(:add_description!, true)
args << options
atp.send(method, *args, &block)
end
end
alias_method :logprint, :log
def lo_limit(value, options)
{
value: value,
rule: options[:rule] || :gte,
units: options[:units],
selector: options[:selector] || options[:test_mode]
}
end
def hi_limit(value, options)
{
value: value,
rule: options[:rule] || :lte,
units: options[:units],
selector: options[:selector] || options[:test_mode]
}
end
def limit(value, options)
unless options[:rule]
fail 'You must supply option :rule (e.g. rule: :gt) when calling the limit helper'
end
{
value: value,
rule: options[:rule] || :lt,
units: options[:units],
selector: options[:selector] || options[:test_mode]
}
end
end
end