diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-09-22 19:23:12 +0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-09-22 19:26:22 +0400 |
commit | 6ddbee5d89b3ea0e5d2a8f2b72416dcb7ab39fe5 (patch) | |
tree | 52ae45b4b53cdeaf7e9687ea15d750a99b27513d /config | |
parent | 2cd0caaf7300d18a565cfe304997b42bca12a947 (diff) |
Consolidate all Resque-related initializers into "4_resque"
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/4_resque.rb | 30 | ||||
-rw-r--r-- | config/initializers/resque.rb | 8 | ||||
-rw-r--r-- | config/initializers/resque_authentication.rb | 14 | ||||
-rw-r--r-- | config/initializers/resque_mailer.rb | 1 |
4 files changed, 30 insertions, 23 deletions
diff --git a/config/initializers/4_resque.rb b/config/initializers/4_resque.rb index 5b0087ab025..2a5721ec742 100644 --- a/config/initializers/4_resque.rb +++ b/config/initializers/4_resque.rb @@ -1 +1,31 @@ +# Custom Redis configuration +rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..' +rails_env = ENV['RAILS_ENV'] || 'development' +config_file = File.join(rails_root, 'config', 'resque.yml') + +if File.exists?(config_file) + resque_config = YAML.load_file(config_file) + Resque.redis = resque_config[rails_env] +end + +# Queues Resque.watch_queue(PostReceive.instance_variable_get("@queue")) + +# Authentication +require 'resque/server' +class Authentication + def initialize(app) + @app = app + end + + def call(env) + account = env['warden'].authenticate!(:database_authenticatable, :rememberable, scope: :user) + raise "Access denied" if !account.admin? + @app.call(env) + end +end + +Resque::Server.use Authentication + +# Mailer +Resque::Mailer.excluded_environments = [] diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb deleted file mode 100644 index b333ceeea1a..00000000000 --- a/config/initializers/resque.rb +++ /dev/null @@ -1,8 +0,0 @@ -rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..' -rails_env = ENV['RAILS_ENV'] || 'development' -config_file = File.join(rails_root, 'config', 'resque.yml') - -if File.exists?(config_file) - resque_config = YAML.load_file(config_file) - Resque.redis = resque_config[rails_env] -end diff --git a/config/initializers/resque_authentication.rb b/config/initializers/resque_authentication.rb deleted file mode 100644 index a439d322804..00000000000 --- a/config/initializers/resque_authentication.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'resque/server' -class Authentication - def initialize(app) - @app = app - end - - def call(env) - account = env['warden'].authenticate!(:database_authenticatable, :rememberable, scope: :user) - raise "Access denied" if !account.admin? - @app.call(env) - end -end - -Resque::Server.use Authentication
\ No newline at end of file diff --git a/config/initializers/resque_mailer.rb b/config/initializers/resque_mailer.rb deleted file mode 100644 index cec9dec9d0e..00000000000 --- a/config/initializers/resque_mailer.rb +++ /dev/null @@ -1 +0,0 @@ -Resque::Mailer.excluded_environments = [] |