41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/linkage/configuration.rb', line 41
def compare_with(operator, rhs)
if !rhs.is_a?(DataWrapper) || @lhs.static? || rhs.static? || @lhs.side == rhs.side
@side = !@lhs.static? ? @lhs.side : rhs.side
if rhs.is_a?(DataWrapper) && !rhs.static? && @lhs.is_a?(FunctionWrapper) && @lhs.static?
@lhs.dataset = rhs.dataset
@lhs.side = @side
elsif @lhs.is_a?(DataWrapper) && !@lhs.static? && rhs.is_a?(FunctionWrapper) && rhs.static?
rhs.dataset = @lhs.dataset
rhs.side = @side
end
elsif rhs.is_a?(DataWrapper) && operator != :==
comparator = Comparators::Compare.new(@lhs.meta_object,
MetaObject.new(operator.to_s), rhs.meta_object)
score_range = Comparators::Compare.score_range
threshold = @type == :must ? score_range.last : score_range.first
expectation = Expectations::Exhaustive.new(comparator, threshold, :equal)
@dsl.add_exhaustive_expectation(expectation)
return self
end
exp_operator = @type == :must_not ? OPERATOR_OPPOSITES[operator] : operator
rhs_meta_object = rhs.is_a?(DataWrapper) ? rhs.meta_object : MetaObject.new(rhs)
@expectation = Expectations::Simple.create(@lhs.meta_object,
rhs_meta_object, exp_operator)
@dsl.add_simple_expectation(@expectation)
self
end
|