Class: ServiceRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/edi/service_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:) ⇒ ServiceRunner

Returns a new instance of ServiceRunner.



4
5
6
# File 'lib/edi/service_runner.rb', line 4

def initialize(message:)
  @message = message
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/edi/service_runner.rb', line 3

def message
  @message
end

#serviceObject

Returns the value of attribute service.



3
4
5
# File 'lib/edi/service_runner.rb', line 3

def service
  @service
end

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/edi/service_runner.rb', line 8

def execute
  self.service = EDI::Interpreter.new(message).determine_service.new(message)
  EDI::Logger.info "Service: #{service.class} invoked"
  begin
    _run_service
  rescue EDI::UnfitEnvironmentException => e
    EDI::ArrayResponder.new(EDI.config.unfit_environment_response).respond
  rescue EDI::ThirdPartyAPIFailure
    EDI::ArrayResponder.new(EDI.config.third_party_api_failure_respone).respond
  rescue => e
    EDI::ArrayResponder.new(EDI.config.standard_error_response).respond
  end
end