Sha256: 17c4ddf10db3a083036d8a40369fa319531b71dcecab8716e8db31df28cc4afb

Contents?: true

Size: 510 Bytes

Versions: 1

Compression:

Stored size: 510 Bytes

Contents

require_relative 'receiver'
require_relative 'registrar'

module Kamerling
  class Handler
    def initialize(receiver: Receiver, registrar: Registrar)
      @receiver, @registrar = receiver, registrar
    end

    def handle(message, addr)
      case message.type
      when :RGST then registrar.register addr: addr, message: message
      when :RSLT then receiver.receive   addr: addr, message: message
      end
    end

    attr_reader :receiver, :registrar
    private     :receiver, :registrar
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.3 lib/kamerling/handler.rb