Project

memor

0.0
No commit activity in last 3 years
No release in over 3 years
memoize function without alias method chain
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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
      # this block would explicitly depend on the 'age' state of current instance
      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.3, 2.0.0 and 2.1.1 Build Status