diff options
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. |