Sha256: 535eb86f0b969142e9b717fc2e83418a961784a7cbf9de6af3c1f52bcdd2dabb

Contents?: true

Size: 670 Bytes

Versions: 2

Compression:

Stored size: 670 Bytes

Contents

$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require 'bundler'
Bundler.setup(:default, :test)

require "lolitra"

class TestBus
  def initialize
    @handlers = {}
    @unmarshallers = {}
  end

  def publish_directly(message_key, message_payload)
    publish(@unmarshallers[message_key].unmarshall(message_payload))
  end

  def publish(message)
    @handlers[message.class.name].each do |handler|
      handler.handle(message)
    end
  end

  def subscribe(message_class, handler_class)
    @unmarshallers[message_class.message_key] = message_class
    @handlers[message_class.name] ||= []
    @handlers[message_class.name] << handler_class
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolitra-0.0.3 spec/spec_helper.rb
lolitra-0.0.2 spec/spec_helper.rb