Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document alternative ways of reloading #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,19 @@ Reload
Each memoized function comes with a way to flush the existing value.

```ruby
person.social_security # returns the memoized value
person.social_security(true) # bypasses the memoized value and rememoizes it
person.social_security # returns the memoized value
person.social_security(true) # bypasses the memoized value and rememoizes it
person.social_security(:reload) # same as above
person.social_security(reload: true) # same as above
```

This also works with a memoized method with arguments

```ruby
person.taxes_due(100_000) # returns the memoized value
person.taxes_due(100_000, true) # bypasses the memoized value and rememoizes it
person.taxes_due(100_000) # returns the memoized value
person.taxes_due(100_000, true) # bypasses the memoized value and rememoizes it
person.taxes_due(100_000, :reload) # same as above
person.taxes_due(100_000, reload: true) # same as above
```

If you want to flush the entire memoization cache for an object
Expand Down