Module: Axiom::Optimizer::Optimizable
- Includes:
- Adamantium
- Defined in:
- lib/axiom/optimizer/optimizable.rb
Overview
Allow operations to be optimizable
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(descendant) ⇒ self
private
Hook called when module is included.
Instance Method Summary collapse
-
#optimize ⇒ Optimizable
Optimize the operation.
Class Method Details
.included(descendant) ⇒ self
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/axiom/optimizer/optimizable.rb', line 18 def self.included(descendant) descendant.extend ClassMethods self end |
Instance Method Details
#optimize ⇒ Optimizable
TODO:
simplify by setting a default Identity optimizer for all relations
Optimize the operation
34 35 36 37 38 39 40 41 42 |
# File 'lib/axiom/optimizer/optimizable.rb', line 34 def optimize optimizer = self.class.optimizer || Optimizer::Identity optimized = optimizer.call(self) if equal?(optimized) then self elsif optimized.respond_to?(:optimize) then optimized.optimize else optimized end end |