Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Simple memoize function without alias method chain

branch: master

readme

latest commit 474a6d4d3f
Aaron Tian authored
README.md

Memor

USAGE

This lib has one utility method called memor which takes binding as an argument, see the following example:

  require 'memor'

  class Foo
    include Memor

    attr_accessor :age

    def slow_method1
      memor binding do
        # slow stuff
      end
    end

    def slow_method2(a, b)
      memor binding do
        # slow stuff
      end
    end

    def slow_method3(a, *args)
      memor binding do
        # slow stuff
      end
    end

    def double_age
      memor binding, :age do
        age * 2
      end
    end

  end

  foo = Foo.new

  foo.age = 2
  foo.double_age # 4

  foo.age = 3
  foo.double_age # 6

Tested in ruby 1.9.2, 1.9.3 and 2.0.0 Build Status

Something went wrong with that request. Please try again.