Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthewrudy/memoist2
Simple Memoization for Ruby 2.0
https://github.com/matthewrudy/memoist2
Last synced: 3 months ago
JSON representation
Simple Memoization for Ruby 2.0
- Host: GitHub
- URL: https://github.com/matthewrudy/memoist2
- Owner: matthewrudy
- License: mit
- Created: 2013-01-19T17:09:25.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-09-21T16:04:31.000Z (about 7 years ago)
- Last Synced: 2024-05-04T09:42:29.905Z (6 months ago)
- Language: Ruby
- Size: 18.6 KB
- Stars: 27
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
memoist2
========[![Build Status](https://travis-ci.org/matthewrudy/memoist2.png?branch=master)](https://travis-ci.org/matthewrudy/memoist2)
Simple Memoization for Ruby 2.0+.
### Differences between Memoist & Memoist2
Unlike [Memoist], this is **not** a drop-in replacement for old ActiveSupport::Memoizable. Memoist will still work just fine for that if you're using Ruby 2.0+. This project, on the other hand, is just me playing using Module#prepend which makes this stuff very simple.
**[Memoist]**
* Works on all Rubies.
* Is quite complicated.
* Has the exact same api as `ActiveSupport::Memoizable`.**Memoist2**
* Only works on `Ruby >= 2.0.0`.
* Is deliberately much simpler.
* Has a slightly different API that could totally change.[Memoist]: https://github.com/matthewrudy/memoist
Example
-------Memoize an instance method
class Foo
include Memoist2
def bar
sleep 1 && 2**10
end
memoize :bar
endMemoize a class method
class Foo
include Memoist2
def self.bar
# something expensive
end
memoize_class_method :bar
endLicence
-------Licensed under the MIT licence.
See the file LICENCE.