class Mumukit::Nuntius::EventConsumer::Builder

Public Class Methods

new() click to toggle source
# File lib/mumukit/nuntius/event_consumer.rb, line 3
def initialize
  @handlers = {}
end

Public Instance Methods

build() click to toggle source
# File lib/mumukit/nuntius/event_consumer.rb, line 11
def build
  @handlers.with_indifferent_access
end
event(key, &block) click to toggle source
# File lib/mumukit/nuntius/event_consumer.rb, line 7
def event(key, &block)
  @handlers[key] = with_database_reconnection &block
end

Private Instance Methods

with_database_reconnection(&block) click to toggle source
# File lib/mumukit/nuntius/event_consumer.rb, line 17
def with_database_reconnection(&block)
  return block unless defined? ActiveRecord
  proc do |*args|
    ActiveRecord::Base.connection_pool.with_connection do
      block.call(*args)
    end
  end
end