Sha256: 9ffe9a9d672b2753adc14ba005e5fe5ff723ae2c5b764506527c7d0b3d29f013
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# Mize ## Description Library to memoize methods or functions in Ruby. ## Installation You can use rubygems to fetch the gem and install it for you: # gem install mize You can also put this line into your Gemfile gem 'mize' and bundle. ## Usage Memoizes methods, that is the values depend on the receiver, like this: ``` class A @@c = 0 memoize method: def foo(x) "foo #{x} #{@@c += 1}" end end a1 = A.new a1.foo(23) # => "foo 23 1" a1.foo(23) # => "foo 23 1" a2 = A.new a2.foo(23) # => "foo 23 2" a2.foo(23) # => "foo 23 2" a2.mize_cache_clear a2.foo(23) # => "foo 23 3" a1.foo(23) # => "foo 23 1" ``` Memoizes functions, that is the values do not depend on the receiver, like this: ``` class B @@c = 0 memoize function: def foo(x) "foo #{x} #{@@c += 1}" end end b1 = B.new b1.foo(23) # => "foo 23 1" b1.foo(23) # => "foo 23 1" b2 = B.new b2.foo(23) # => "foo 23 1" b2.foo(23) # => "foo 23 1" B.mize_cache_clear b2.foo(23) # => "foo 23 2" b1.foo(23) # => "foo 23 2" ``` ## Download The homepage of this library is located at * https://github.com/flori/mize ## Author [Florian Frank](mailto:flori@ping.de) ## License This software is licensed under MIT license.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mize-0.6.0 | README.md |
mize-0.5.0 | README.md |