lib/emittance/brokerage.rb in emittance-0.0.3 vs lib/emittance/brokerage.rb in emittance-0.0.4

- old
+ new

@@ -5,16 +5,24 @@ # The clearinghouse for brokers. Registers brokers, and decides which broker to use when sent an event. First point of # contact for event propagation. # class Brokerage @enabled = true + @current_broker = nil class << self # @param event [Emittance::Event] the event object # @param broker_id [Symbol] a symbol that can be used to identify a broker by - def send_event(event, broker_id) - broker = registry.fetch(broker_id) + def send_event(event) broker.process_event event + end + + def broker + @current_broker + end + + def use_broker(identifier) + @current_broker = registry.fetch identifier end # @param broker [Emittance::Broker] the broker you would like to register def register_broker(broker) registry.register broker