Module: Veritas::Optimizer::Optimizable

Includes:
Adamantium
Defined in:
lib/veritas/optimizer/optimizable.rb

Overview

Allow operations to be optimizable

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (self) included(descendant)

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.

Hook called when module is included



18
19
20
21
# File 'lib/veritas/optimizer/optimizable.rb', line 18

def self.included(descendant)
  descendant.extend ClassMethods
  self
end

Instance Method Details

- (Optimizable) optimize

TODO:

simplify by setting a default Identity optimizer for all relations

Optimize the operation

Examples:

optimized = operation.optimize


34
35
36
37
38
39
40
# File 'lib/veritas/optimizer/optimizable.rb', line 34

def optimize
  optimizer = self.class.optimizer || Optimizer::Identity
  optimized = optimizer.call(self)
  equal?(optimized)                ? self               :
  optimized.respond_to?(:optimize) ? optimized.optimize :
                                     optimized
end