Sha256: 971798c83440314bd539fc139abaf62079f901184ba6449bd8cd498973522a8c
Contents?: true
Size: 499 Bytes
Versions: 1
Compression:
Stored size: 499 Bytes
Contents
require "mem/version" module Mem def memoize(method_name) define_method("#{method_name}_with_memoize") do |*args, &block| if instance_variable_defined?("@#{method_name}") instance_variable_get("@#{method_name}") else instance_variable_set("@#{method_name}", send("#{method_name}_without_memoize", *args, &block)) end end alias_method "#{method_name}_without_memoize", method_name alias_method method_name, "#{method_name}_with_memoize" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mem-0.0.2 | lib/mem.rb |