Skip to content

Commit

Permalink
Railtie to perform Rails 3 initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mjonuschat authored and bkeepers committed Apr 8, 2010
1 parent e9b1573 commit 3e0fc41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/delayed/railtie.rb
@@ -0,0 +1,17 @@
require 'delayed_job'
require 'rails'

module Delayed
class Railtie < Rails::Railtie
initializer :after_initialize do
Delayed::Worker.backend ||= if defined?(ActiveRecord)
:active_record
elsif defined?(MongoMapper)
:mongo_mapper
else
Delayed::Worker.logger.warn "Could not decide on a backend, defaulting to active_record"
:active_record
end
end
end
end
1 change: 1 addition & 0 deletions lib/delayed_job.rb
Expand Up @@ -4,6 +4,7 @@
require File.dirname(__FILE__) + '/delayed/performable_method'
require File.dirname(__FILE__) + '/delayed/backend/base'
require File.dirname(__FILE__) + '/delayed/worker'
require File.dirname(__FILE__) + '/delayed/railtie' if defined?(::Rails::Railtie)

Object.send(:include, Delayed::MessageSending)
Module.send(:include, Delayed::MessageSending::ClassMethods)
Expand Down

0 comments on commit 3e0fc41

Please sign in to comment.