Sha256: ae41a56200fbc5bc7fcd694e69271094fbeb597333701374d6dae4b622271866

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8

module Axiom
  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 EmptyRight < self
            include Enumerable::EmptyRight, Predicate::Contradiction
          end # class EmptyRight

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

            # An Inclusion with a single right operand is equivalent to an Equality
            #
            # @return [Equality]
            #
            # @api private
            def optimize
              left.eq(right.first)
            end

          end # class OneRight

          Axiom::Function::Predicate::Inclusion.optimizer = chain(
            ConstantOperands,
            EmptyRight,
            OneRight,
            Enumerable::UnoptimizedOperands
          )

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 lib/axiom/optimizer/function/predicate/inclusion.rb
axiom-optimizer-0.1.1 lib/axiom/optimizer/function/predicate/inclusion.rb
axiom-optimizer-0.1.0 lib/axiom/optimizer/function/predicate/inclusion.rb