Class: Gitlab::Verify::BatchVerifier
- Inherits:
-
Object
- Object
- Gitlab::Verify::BatchVerifier
- Defined in:
- lib/gitlab/verify/batch_verifier.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#finish ⇒ Object
readonly
Returns the value of attribute finish.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #describe(_object) ⇒ Object
-
#initialize(batch_size:, start: nil, finish: nil) ⇒ BatchVerifier
constructor
A new instance of BatchVerifier.
- #name ⇒ Object
-
#run_batches(&blk) ⇒ Object
Yields a Range of IDs and a Hash of failed verifications (object => error).
Constructor Details
#initialize(batch_size:, start: nil, finish: nil) ⇒ BatchVerifier
Returns a new instance of BatchVerifier.
8 9 10 11 12 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 8 def initialize(batch_size:, start: nil, finish: nil) @batch_size = batch_size @start = start @finish = finish end |
Instance Attribute Details
#batch_size ⇒ Object (readonly)
Returns the value of attribute batch_size.
6 7 8 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 6 def batch_size @batch_size end |
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
6 7 8 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 6 def finish @finish end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
6 7 8 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 6 def start @start end |
Instance Method Details
#describe(_object) ⇒ Object
28 29 30 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 28 def describe(_object) raise NotImplementedError end |
#name ⇒ Object
24 25 26 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 24 def name raise NotImplementedError end |
#run_batches(&blk) ⇒ Object
Yields a Range of IDs and a Hash of failed verifications (object => error)
15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/verify/batch_verifier.rb', line 15 def run_batches(&blk) all_relation.in_batches(of: batch_size, start: start, finish: finish) do |batch| # rubocop: disable Cop/InBatches range = batch.first.id..batch.last.id failures = run_batch_for(batch) yield(range, failures) end end |