Class: Veritas::Optimizer::Function::Predicate::Comparable::NormalizableOperands

Inherits:
Veritas::Optimizer::Function::Predicate show all
Defined in:
lib/veritas/optimizer/function/predicate/comparable.rb

Overview

Optimize when the operands can be normalized

Constant Summary

Constants inherited from Veritas::Optimizer

Noop, VERSION

Instance Attribute Summary

Attributes included from Binary

#left, #right

Attributes inherited from Veritas::Optimizer

#operation

Instance Method Summary collapse

Methods included from Binary

#initialize

Methods inherited from Veritas::Optimizer

chain, #initialize

Instance Method Details

#optimizable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if the operands can be normalized

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/veritas/optimizer/function/predicate/comparable.rb', line 19

def optimizable?
  util = Util
  util.constant?(left) && util.attribute?(right)
end

#optimizePredicate

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Normalize the predicate by reversing the operands

Returns:



29
30
31
# File 'lib/veritas/optimizer/function/predicate/comparable.rb', line 29

def optimize
  operation.class.reverse.new(right, left)
end