Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns/uniquify.rb')
-rw-r--r--app/models/concerns/uniquify.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/concerns/uniquify.rb b/app/models/concerns/uniquify.rb
index a7fe5951b6e..db51ed2dbeb 100644
--- a/app/models/concerns/uniquify.rb
+++ b/app/models/concerns/uniquify.rb
@@ -3,11 +3,14 @@ class Uniquify
# by appending a counter to it. Uniqueness is determined by
# repeated calls to the passed block.
#
+ # You can pass an initial value for the counter, if not given
+ # counting starts from 1.
+ #
# If `base` is a function/proc, we expect that calling it with a
# candidate counter returns a string to test/return.
- def string(base)
+ def string(base, counter = nil)
@base = base
- @counter = nil
+ @counter = counter
increment_counter! while yield(base_string)
base_string