Sha256: 350b7044cc76657c7f25e04899fc759df7080d709dbffbf1aca834f63bf07bd4

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

class MessageRouter
  # Mount routers inside of routers.
  class Mount
    def initialize(mounted_router_klass)
      @mounted_router_klass = mounted_router_klass
    end

    def call(router)
      mounted_router = mounted_router_klass.new(router.message)
      response = mounted_router.dispatch
      # If the mounted router was halted, halt this router and pass through the response
      mounted_router.halted? ? router.halt(response) : response
    end

  private
    attr_reader :mounted_router_klass
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message_router-0.0.2 lib/message_router/mount.rb
message_router-0.0.1 lib/message_router/mount.rb