Sha256: 07637c41a2a3d5a3980f53f15be1612921e667b12fb4473f86ddb83c9f8e0235
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
module Veritas # Allow operations to be optimizable module Optimizable include Immutable # Hook called when module is included # # @param [Module] descendant # the module or class including Optimizable # # @return [self] # # @api private def self.included(descendant) descendant.extend ClassMethods self end # Optimize the operation # # @example # optimized = operation.optimize # # @param [Optimizer] optimizer # optional optimizer # # @return [Optimizable] # the optimized operation # # @api public def optimize(optimizer = self.class.optimizer) return self if optimizer.nil? optimized = optimizer.call(self) optimized.memoize(:optimize, optimized) end memoize :optimize module ClassMethods # The Optimizer for the operation # # @return [Optimizable] # # @api private attr_accessor :optimizer end # module ClassMethods end # module Optimizable end # module Veritas
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | lib/veritas/support/optimizable.rb |
veritas-0.0.1 | lib/veritas/support/optimizable.rb |