Sha256: d55f2b8cf1e4176700b5198f1adddf198a07a264b3c43e8323a30ae50b88cc37

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

require "reactor/version"
require "reactor/models/concerns/publishable"
require "reactor/models/concerns/subscribable"
require "reactor/models/concerns/optionally_subclassable"
require "reactor/models/subscriber"
require "reactor/controllers/concerns/resource_actionable"
require "reactor/event"

module Reactor
  SUBSCRIBERS = {}
  TEST_MODE_SUBSCRIBERS = Set.new
  @@test_mode = false

  module StaticSubscribers
  end

  def self.test_mode?
    @@test_mode
  end

  def self.test_mode!
    @@test_mode = true
  end

  def self.disable_test_mode!
    @@test_mode = false
  end

  def self.in_test_mode
    test_mode!
    (yield if block_given?).tap { disable_test_mode! }
  end

  def self.enable_test_mode_subscriber(klass)
    TEST_MODE_SUBSCRIBERS << klass
  end

  def self.disable_test_mode_subscriber(klass)
    TEST_MODE_SUBSCRIBERS.delete klass
  end

  def self.with_subscriber_enabled(klass)
    enable_test_mode_subscriber klass
    yield if block_given?
    disable_test_mode_subscriber klass
  end
end

# Temporarily avoid Rails 4.2.0 deprecation warning
if ActiveRecord::VERSION::STRING > '4.2'
  ActiveRecord::Base.raise_in_transactional_callbacks = true
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
reactor-0.12.1 lib/reactor.rb
reactor-0.11.4 lib/reactor.rb
reactor-0.11.2 lib/reactor.rb
reactor-0.11.1 lib/reactor.rb
reactor-0.11.0 lib/reactor.rb
reactor-0.10.1 lib/reactor.rb
reactor-0.10.0 lib/reactor.rb
reactor-0.9.9 lib/reactor.rb
reactor-0.9.8 lib/reactor.rb
reactor-0.9.7 lib/reactor.rb