Class: AtlasEngine::AddressValidation::PredicatePipelineBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matching_strategy_name:, address:, result:, message_format:) ⇒ PredicatePipelineBuilder

Returns a new instance of PredicatePipelineBuilder.



29
30
31
32
33
34
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 29

def initialize(matching_strategy_name:, address:, result:, message_format:)
  @address = address
  @predicate_pipeline = T.let(PredicatePipeline.find(matching_strategy_name), PredicatePipeline)
  @result = result
  @message_format = message_format
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



13
14
15
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 13

def address
  @address
end

#message_formatObject (readonly)

Returns the value of attribute message_format.



19
20
21
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 19

def message_format
  @message_format
end

#predicate_pipelineObject (readonly)

Returns the value of attribute predicate_pipeline.



10
11
12
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 10

def predicate_pipeline
  @predicate_pipeline
end

#resultObject (readonly)

Returns the value of attribute result.



16
17
18
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 16

def result
  @result
end

Instance Method Details

#full_address_validatorObject



44
45
46
47
48
49
50
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 44

def full_address_validator
  predicate_pipeline.full_address_validator&.new(
    address: address,
    result: result,
    message_format: message_format,
  )
end

#pipelineObject



37
38
39
40
41
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 37

def pipeline
  predicate_pipeline.pipeline.reject do |predicate_config|
    unsupported_fields.include?(predicate_config.field)
  end
end

#unsupported_fieldsObject



55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/atlas_engine/address_validation/predicate_pipeline_builder.rb', line 55

def unsupported_fields
  @unsupported_fields ||= T.let(
    begin
      unsupported_fields = []
      unsupported_fields += address1_format == :extended ? [:address1] : [:street_name, :street_number]
      unsupported_fields += address2_format == :extended ? [:address2] : [:line2, :neighborhood]
      unsupported_fields
    end,
    T.nilable(T::Array[T.untyped]),
  )
end