matthewrudy / memoist

ActiveSupport::Memoizable with a few enhancements
MIT License
920 stars 99 forks source link

Place sample code for execution in README.md #72

Closed 3nan3 closed 4 years ago

3nan3 commented 6 years ago

I tried Usage and I thought that it would be better to write how to check the operation of memoization.

e.g.

require 'memoist'

class Example
  extend Memoist

  def some_method
    puts "execute!"
    Time.now
  end
  memoize :some_method
end

example = Example.new

example.some_method
# execute!
# => 2018-03-26 14:43:39 +0000

example.some_method
# => 2018-03-26 14:43:39 +0000