Sha256: 1196b4ce12e076d72d3719c8a6a5bc483ce0ea072a30984a7bcaf76d675fd8f4
Contents?: true
Size: 543 Bytes
Versions: 3
Compression:
Stored size: 543 Bytes
Contents
module MonkeySupport module Memoizable # This is faster than AS::Memoizeable. # Less featureful, however. def monkey_memoize(*methods) methods.each do |method| class_eval <<EOS @__memo_#{method} = {} alias_method :__unmemo_#{method}, :#{method} if method(:#{method}).arity == 1 def #{method}(arg) @__memo_#{method}[arg] ||= __unmemo_#{method}(arg) end else def #{method}(*args) @__memo_#{method}[args] ||= __unmemo_#{method}(*args) end end EOS end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
monkeysupport-1.0.0 | lib/monkeysupport/memoizable.rb |
monkeysupport-0.2.0 | lib/monkeysupport/memoizable.rb |
monkeysupport-0.1.2 | lib/monkeysupport/memoizable.rb |