Sha256: 0b80c4a290307f6f48790544d7c9e563ceaf8516ee647ee1e2dae926488a1e96

Contents?: true

Size: 528 Bytes

Versions: 3

Compression:

Stored size: 528 Bytes

Contents

# frozen_string_literal: true

module RailwayIpc
  class Handler
    class << self
      attr_reader :block
    end

    def self.handle(&block)
      @block = block
    end

    def handle(message)
      RailwayIpc.logger.info(message, 'Handling message')
      response = self.class.block.call(message)
      if response.success?
        RailwayIpc.logger.info(message, 'Successfully handled message')
      else
        RailwayIpc.logger.error(message, 'Failed to handle message')
      end

      response
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
railway-ipc-1.1.0 lib/railway_ipc/handler.rb
railway-ipc-1.0.1 lib/railway_ipc/handler.rb
railway-ipc-1.0.0 lib/railway_ipc/handler.rb