diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-04-19 09:59:37 +0300 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-04-19 14:56:37 +0300 |
commit | 6ae3098eb8f01406190942e8952866dd9af81dde (patch) | |
tree | 478fd89327d9248b1daadea5f3c80e29fb6180e3 /app/models/concerns/uniquify.rb | |
parent | 4f2e494772eb5f31929ecfdb439dfa4baa56521c (diff) |
Uses Uniquify to calculate Issue#suggested_branch_name
Diffstat (limited to 'app/models/concerns/uniquify.rb')
-rw-r--r-- | app/models/concerns/uniquify.rb | 7 |
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 |