Skip to content

Commit

Permalink
Merge pull request #29 from fervic/doc-identifier
Browse files Browse the repository at this point in the history
Update README with :identifier info
  • Loading branch information
matthewrudy committed Jan 11, 2015
2 parents 34e12e4 + 55fcfca commit 7c63fe5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ You can also memoize class methods.

end

When a sub-class overrides one of its parent's methods and you need to memoize both.
Then you can use the `:identifier` parameter in order to help _Memoist_ distinguish between the two.

class Clock
extend Memoist
def now
"The time now is #{Time.now.hour} o'clock and #{Time.now.min} minutes"
end
memoize :now
end

class AccurateClock < Clock
extend Memoist
def now
"#{super} and #{Time.now.sec} seconds"
end
memoize :now, :identifier => :accurate_clock
end


Reload
------
Expand Down

0 comments on commit 7c63fe5

Please sign in to comment.