rails/rails — comment on commit 36253916b0b788d6ded56669d37c96ed05c92c5c
File:  line 0
By Aaron2Ti:

The ```@var ||=``` way could not cope with functions which having arguments, so I wrote a small gem **[memor](https://github.com/Aaron2Ti/memor)** to solve these problems:

```ruby
class Foo
def bar(arg1, arg2, *args) # have to cache this method
do_something
end
end
```
In order to cache Foo#bar just wrap the existed function inside a memor block:

```ruby
require 'memor'

class Foo
include Memor

def bar(arg1, arg2, *args) # cached per arguments
memor binding do # memor wrapper
do_something
end
end
end
```

We used this gem in one client app to cache heavy statics calculations for reports.