Sha256: e0f8f079d020b4df4713632adc6e908de391e57023756ab4a71aea5342716e49

Contents?: true

Size: 994 Bytes

Versions: 4

Compression:

Stored size: 994 Bytes

Contents

require "active_record"
require "active_support/hash_with_indifferent_access"
require "action_mailer"

require "reactor/version"
require "reactor/errors"
require "reactor/static_subscribers"
require "reactor/workers/concerns/configuration"
require "reactor/workers"
require "reactor/subscription"
require "reactor/models"
require "reactor/controllers"
require "reactor/event"

# FIXME: should only be included in test environments
require "reactor/testing"

module Reactor
  SUBSCRIBERS = {}.with_indifferent_access

  module_function

  def subscribers
    SUBSCRIBERS
  end

  def add_subscriber(event_name, worker_class)
    subscribers[event_name] ||= []
    subscribers[event_name] << worker_class
  end

  def subscribers_for(event_name)
    Array(subscribers[event_name]) + Array(subscribers['*'])
  end

  def subscriber_namespace
    Reactor::StaticSubscribers
  end
end

ActiveRecord::Base.send(:include, Reactor::Publishable)
ActiveRecord::Base.send(:include, Reactor::Subscribable)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reactor-0.18.0 lib/reactor.rb
reactor-0.17.0 lib/reactor.rb
reactor-0.16.1 lib/reactor.rb
reactor-0.16.0 lib/reactor.rb