Module: Cenit::Algorithms

Defined in:
lib/cenit/algorithms.rb,
lib/cenit/algorithms/version.rb,
lib/cenit/algorithms/rewriter.rb,
lib/cenit/algorithms/algorithm.rb,
lib/cenit/algorithms/namespace.rb,
lib/cenit/algorithms/interpreter.rb

Defined Under Namespace

Classes: Algorithm, Interpreter, Namespace, Rewriter

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.find(criteria) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cenit/algorithms.rb', line 26

def find(criteria)
  id = criteria[:id] || criteria['id']
  if (algorithm = cache[id])
    return algorithm
  end
  namespace = criteria[:namespace] || criteria['namespace']
  name = criteria[:name] || criteria['name']
  if namespace && name && (algorithm = indexed[namespace][name])
    return algorithm
  end
  algorithm = retrieve(criteria)
  indexed[algorithm.namespace][algorithm.name] = cache[algorithm.id] = algorithm
  algorithm
end

.resetObject



41
42
43
44
45
# File 'lib/cenit/algorithms.rb', line 41

def reset
  cache.clear
  indexed.clear
  self
end