Module: AdLint::Memoizable

Included in:
Module
Defined in:
lib/adlint/memo.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#memoize(name, *opts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/adlint/memo.rb', line 35

def memoize(name, *opts)
  force_nullary, key_indices = extract_memoize_options(opts)
  case
  when instance_method(name).arity == 0 || force_nullary
    memoize_nullary_method(name)
  when instance_method(name).arity == 1 || key_indices.size == 1
    memoize_unary_method(name, key_indices.first || 0)
  else
    memoize_polynomial_method(name, key_indices)
  end
end