Sha256: 3d75b5b631c5e9b214b8c0e844d97faccb8c103c7ee37118ee89a0f2762e79dd

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

module Veritas
  class Optimizer
    module Function
      class Predicate

        # Abstract base class representing Inclusion optimizations
        class Inclusion < self
          include Enumerable

          # Optimize when the right operand is empty
          class EmptyRightOperand < self
            include Enumerable::EmptyRightOperand, Predicate::Contradiction
          end # class EmptyRightOperand

          # Optimize when the right operand has one entry
          class OneRightOperand < self
            include Enumerable::OneRightOperand

            # An Inclusion with a single right operand is equivalent to an Equality
            #
            # @return [Equality]
            #
            # @api private
            def optimize
              Veritas::Function::Predicate::Equality.new(left, right.first)
            end

          end # class OneRightOperand

          Veritas::Function::Predicate::Inclusion.optimizer = chain(
            ConstantOperands,
            EmptyRightOperand,
            OneRightOperand,
            Enumerable::UnoptimizedOperands
          )

        end # class Inclusion
      end # class Predicate
    end # module Function
  end # class Optimizer
end # module Veritas

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.5 lib/veritas/optimizer/function/predicate/inclusion.rb
veritas-optimizer-0.0.4 lib/veritas/optimizer/function/predicate/inclusion.rb