Sha256: 6cefa5b7c8369f4759ca5fdb08d163a4e8c63f5b7da43f6e2ff27cf6777e1659

Contents?: true

Size: 215 Bytes

Versions: 1

Compression:

Stored size: 215 Bytes

Contents

class Memoize < MethodDecorator
  def initialize
    @cache ||= {}
    super
  end

  def call(orig, *args, &blk)
    return @cache[args] if @cache.has_key?(args)
    @cache[args] = orig.call(*args, &blk)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
method_decorators-0.9.1 lib/method_decorators/decorators/memoize.rb