diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-12 06:10:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-12 06:10:17 +0300 |
commit | 737684a392db1178770ad5b1d20b64386aadcac5 (patch) | |
tree | a5b304cf7cd4d0c41ad3bde432d20edd7d79257d /lib/gitlab/issuables_count_for_state.rb | |
parent | 80ddaef34dd357706187bd888b34e7ca1d5c30ba (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/issuables_count_for_state.rb')
-rw-r--r-- | lib/gitlab/issuables_count_for_state.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/issuables_count_for_state.rb b/lib/gitlab/issuables_count_for_state.rb index 659fb1472d2..7be54a214dd 100644 --- a/lib/gitlab/issuables_count_for_state.rb +++ b/lib/gitlab/issuables_count_for_state.rb @@ -9,9 +9,16 @@ module Gitlab # The state values that can be safely casted to a Symbol. STATES = %w[opened closed merged all].freeze + attr_reader :project + + def self.declarative_policy_class + 'IssuablePolicy' + end + # finder - The finder class to use for retrieving the issuables. - def initialize(finder) + def initialize(finder, project = nil) @finder = finder + @project = project @cache = Gitlab::SafeRequestStore[CACHE_KEY] ||= initialize_cache end @@ -19,6 +26,11 @@ module Gitlab self[state || :opened] end + # Define method for each state + STATES.each do |state| + define_method(state) { self[state] } + end + # Returns the count for the given state. # # state - The name of the state as either a String or a Symbol. |