Skip to content

Commit

Permalink
Docs: Explain that we're memoizing things
Browse files Browse the repository at this point in the history
  • Loading branch information
triskweline committed Sep 5, 2017
1 parent 0fdab64 commit 14f903c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -628,6 +628,25 @@ The `authorize_values_for` macro comes with many useful options and details best
assignable_values_for :field, :through => lambda { Power.current }
```

Memoization
-----------

All power methods are [memoized](https://www.justinweiss.com/articles/4-simple-memoization-patterns-in-ruby-and-one-gem/) for performance reasons. Multiple calls to the same method will only call your block the first time, and return a cached result afterwards:

```
power = Power.new
power.projects! # calls the `power :projects { ... }` block
power.projects! # returns the cached result from earlier
power.projects! # returns the cached result from earlier
```

If you want to discard all cached results, call `#unmemoize_all`:

```
power.unmemoize_all
```


Dynamic power access
--------------------

Expand Down

0 comments on commit 14f903c

Please sign in to comment.