Skip to content

Commit

Permalink
Clarify what memoize is doing
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcsmith committed Jun 9, 2020
1 parent b8872d8 commit 4011f85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Api::Auth::Helpers
def current_user? : User?
# The 'memoize' macro makes sure only one query is issued to find the user
memoize def current_user? : User?
auth_token.try do |value|
user_from_auth_token(value)
end
Expand Down
3 changes: 2 additions & 1 deletion src/browser_app_skeleton/src/actions/browser_action.cr.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ abstract class BrowserAction < Lucky::Action
expose current_user

# This method tells Authentic how to find the current user
memoize def find_current_user(id) : User?
# The 'memoize' macro makes sure only one query is issued to find the user
private memoize def find_current_user(id) : User?
UserQuery.new.id(id).first?
end
<%- end -%>
Expand Down

0 comments on commit 4011f85

Please sign in to comment.