diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-02-20 19:04:10 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-02-20 19:04:10 -0300 |
commit | 70156f3b8e277ffeba2a6c37d15ec2669fb432d7 (patch) | |
tree | 29e18aec5e18fb127a55116541a72c65d76b05d0 /app/presenters/project_presenter.rb | |
parent | 1521fd9f5ca6e19d282bbd7253e64d741ab44380 (diff) | |
download | gitlab-ce-70156f3b8e277ffeba2a6c37d15ec2669fb432d7.tar.gz |
Memoize method which is called multiple times on presenter
Diffstat (limited to 'app/presenters/project_presenter.rb')
-rw-r--r-- | app/presenters/project_presenter.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 8dca777212e..843651682eb 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -4,6 +4,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated include GitlabRoutingHelper include StorageHelper include TreeHelper + include Gitlab::Utils::StrongMemoize presents :project @@ -159,10 +160,12 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end def can_current_user_push_code? - if empty_repo? - can?(current_user, :push_code, project) - else - user_can_push_to_branch?(current_user, default_branch) + strong_memoize(:can_current_user_push_code) do + if empty_repo? + can?(current_user, :push_code, project) + else + user_can_push_to_branch?(current_user, default_branch) + end end end |