Permalink
Browse files

Got activemessaging to load in a rails 3 app.

  • Loading branch information...
1 parent 9a1d5bb commit e1bb98465cf4c91d99547f94dfce2b0a0e87376f @spraints committed Jun 15, 2010
Showing with 20 additions and 25 deletions.
  1. +5 −10 lib/activemessaging.rb
  2. +15 −15 lib/activemessaging/support.rb
@@ -1,6 +1,6 @@
module ActiveMessaging
- APP_ROOT = ENV['APP_ROOT'] || ENV['RAILS_ROOT'] || ((defined? RAILS_ROOT) && RAILS_ROOT) || File.dirname($0)
- APP_ENV = ENV['APP_ENV'] || ENV['RAILS_ENV'] || 'development'
+ APP_ROOT = ENV['APP_ROOT'] || ((defined? Rails) && Rails.root) || ENV['RAILS_ROOT'] || File.dirname($0)
+ APP_ENV = ENV['APP_ENV'] || ((defined? Rails) && Rails.env) || ENV['RAILS_ENV'] || 'development'
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Used to indicate that the processing for a thread shoud complete
@@ -19,7 +19,7 @@ class StopFilterException < Exception #:nodoc:
def ActiveMessaging.logger
@@logger = nil unless defined? @@logger
- @@logger ||= Rails.logger
+ @@logger ||= Rails.logger if defined? Rails
@@logger ||= ActiveRecord::Base.logger if defined? ActiveRecord
@@logger ||= Logger.new(STDOUT)
@@logger
@@ -119,12 +119,7 @@ class DoSomethingProcessor < ActiveMessaging::Processor
# reload these on each Rails request - leveraging Dispatcher semantics for consistency
if defined? Rails
ActiveMessaging.logger.info "Rails available: Adding dispatcher prepare callback."
- require 'dispatcher' unless defined?(::Dispatcher)
-
- # add processors and config to on_prepare if supported (rails 1.2+)
- if ::Dispatcher.respond_to? :to_prepare
- ::Dispatcher.to_prepare :activemessaging do
- ActiveMessaging.reload_activemessaging
- end
+ ActionDispatch::Callbacks.to_prepare :activemessaging do
+ ActiveMessaging.reload_activemessaging
end
end
@@ -1,17 +1,17 @@
if defined? Rails
- ActiveMessaging.logger.debug "Rails available: Adding reload hooks."
- require 'dispatcher' unless defined?(::Dispatcher)
- ::Dispatcher.class_eval do
-
- def self.prepare_application_for_dispatch
- disp = new(STDOUT)
- disp.run_callbacks :before_dispatch
- end
-
- def self.reset_application_after_dispatch
- disp = new(STDOUT)
- disp.run_callbacks :after_dispatch, :enumerator => :reverse_each
- end
-
- end
+# ActiveMessaging.logger.debug "Rails available: Adding reload hooks."
+# require 'dispatcher' unless defined?(::Dispatcher)
+# ::Dispatcher.class_eval do
+#
+# def self.prepare_application_for_dispatch
+# disp = new(STDOUT)
+# disp.run_callbacks :before_dispatch
+# end
+#
+# def self.reset_application_after_dispatch
+# disp = new(STDOUT)
+# disp.run_callbacks :after_dispatch, :enumerator => :reverse_each
+# end
+#
+# end
end

0 comments on commit e1bb984

Please sign in to comment.