Class: AtlasEngine::AddressValidation::Es::Validators::FullAddress

Inherits:
FullAddressValidatorBase show all
Includes:
LogHelper
Defined in:
app/models/atlas_engine/address_validation/es/validators/full_address.rb

Direct Known Subclasses

FullAddressStreet

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LogHelper

#log_error, #log_info, #log_warn

Constructor Details

#initialize(address:, result: Result.new, message_format: MessageFormat::Instructional) ⇒ FullAddress

Returns a new instance of FullAddress.



14
15
16
17
18
# File 'app/models/atlas_engine/address_validation/es/validators/full_address.rb', line 14

def initialize(address:, result: Result.new, message_format: MessageFormat::Instructional)
  super
  @matching_strategy = MatchingStrategies::Es
  @message_format = message_format
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



11
12
13
# File 'app/models/atlas_engine/address_validation/es/validators/full_address.rb', line 11

def address
  @address
end

#message_formatObject (readonly)

Returns the value of attribute message_format.



11
12
13
# File 'app/models/atlas_engine/address_validation/es/validators/full_address.rb', line 11

def message_format
  @message_format
end

#resultObject (readonly)

Returns the value of attribute result.



11
12
13
# File 'app/models/atlas_engine/address_validation/es/validators/full_address.rb', line 11

def result
  @result
end

Instance Method Details

#build_candidate_resultObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/atlas_engine/address_validation/es/validators/full_address.rb', line 31

def build_candidate_result
  unless supported_address?(address)
    return AddressValidation::Validators::FullAddress::UnsupportedScriptResult.new(
      address:,
      result:,
      message_format:,
    )
  end

  if best_candidate.nil?
    AddressValidation::Validators::FullAddress::NoCandidateResult.new(
      address:, result:, message_format:,
    )
  else
    AddressValidation::Validators::FullAddress::CandidateResult.new(
      address_comparison: T.must(best_candidate),
      matching_strategy: @matching_strategy,
      result: result,
      message_format:,
    )
  end
end

#validateObject



21
22
23
24
25
26
27
28
# File 'app/models/atlas_engine/address_validation/es/validators/full_address.rb', line 21

def validate
  return result if concerns_preclude_validation

  candidate_result = build_candidate_result
  candidate_result.update_result
  publish_notification(candidate_result: candidate_result)
  result
end