txus/rubinius-memoize
Method memoization using Rubinius AST transforms
{ "createdAt": "2013-11-12T20:49:21Z", "defaultBranch": "master", "description": "Method memoization using Rubinius AST transforms", "fullName": "txus/rubinius-memoize", "homepage": "https://github.com/txus/rubinius-memoize", "language": "Ruby", "name": "rubinius-memoize", "pushedAt": "2015-08-21T09:36:42Z", "stargazersCount": 3, "topics": [], "updatedAt": "2021-07-16T06:16:55Z", "url": "https://github.com/txus/rubinius-memoize"}rubinius-memoize 
Section titled “rubinius-memoize ”Method memoization using [Rubinius][rubinius] AST transforms.
Installation
Section titled “Installation”Add this line to your application’s Gemfile:
gem 'rubinius-memoize'And then execute:
$ bundleOr install it yourself as:
$ gem install rubinius-memoizeCaveats
Section titled “Caveats”For now it only supports methods with zero arguments.
Also, it only works on Rubinius 2.0+.
Warning if you don’t use Bundler (if you do you’re fine)
Section titled “Warning if you don’t use Bundler (if you do you’re fine)”Since it extends the compiler at runtime, from the moment that you require 'rubinius/memoize', the memoize method will only be available in files
required after that.
That means that this won’t work:
require 'rubinius/memoize'
class Shawarma memoize def foo 3 endendBut this will:
require 'rubinius/memoize'require 'shawarma'class Shawarma memoize def foo expensive_operation endend
adonis = Shawarma.newadonis.foo # takes a whileadonis.foo # instant!
# Want to expire the memoized method? Be my guest:Rubinius::Memoize.expire(adonis, :foo)
adonis.foo # takes a while againWho’s this
Section titled “Who’s this”This was made by Josep M. Bach (Txus) under the MIT license. I’m [@txustice][twitter] on twitter (where you should probably follow me!).
[twitter] !: https://twitter.com/txustice [rubinius] !: http://rubini.us