Class: AddressFinder::V1::Nz::BatchVerification

Inherits:
Object
  • Object
show all
Defined in:
lib/addressfinder/v1/nz/batch_verification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addresses:, http: nil, concurrency: 2, **args) ⇒ BatchVerification

Verifies an array of addresses using concurrency to reduce the execution time.

The results of the verification are stored in the ‘results` attribute, in the same order in which they were supplied.

Parameters:

  • addresses (Array<String>)

    array of address query strings

  • http (AddressFinder::HTTP) (defaults to: nil)

    HTTP connection helper

  • concurrency (Integer) (defaults to: 2)

    How many threads to use for verification

  • args (Hash)

    Any additional arguments that will be passed onto the Address Verification API



16
17
18
19
20
21
# File 'lib/addressfinder/v1/nz/batch_verification.rb', line 16

def initialize(addresses:, http: nil, concurrency: 2, **args)
  @addresses = addresses
  @concurrency = concurrency
  @http = http
  @args = args
end

Instance Attribute Details

#addressesObject (readonly)

Returns the value of attribute addresses.



5
6
7
# File 'lib/addressfinder/v1/nz/batch_verification.rb', line 5

def addresses
  @addresses
end

#resultsObject (readonly)

Returns the value of attribute results.



5
6
7
# File 'lib/addressfinder/v1/nz/batch_verification.rb', line 5

def results
  @results
end

Instance Method Details

#performObject



23
24
25
26
27
28
# File 'lib/addressfinder/v1/nz/batch_verification.rb', line 23

def perform
  confirm_concurrency_level
  verify_each_address_concurrently

  self
end