# File lib/spruz/memoize.rb, line 52 def memoize_function(*function_ids) mc = @__memoize_cache__ ||= {} function_ids.each do |method_id| orig_method = instance_method(method_id) __send__(:define_method, method_id) do |*args| if mc.key?(args) result = mc[args] else result = mc[args] = orig_method.bind(self).call(*args) if $DEBUG warn "#{self.class} cached function #{method_id}(#{args.inspect unless args.empty?}) = #{result.inspect}" end end result end end end