From 17b5e7b066361b92f410f598e2e7ad9ac166c62b Mon Sep 17 00:00:00 2001
From: Maxwell Salzberg <maxwell@joindiaspora.com>
Date: Fri, 16 Sep 2011 13:33:05 -0700
Subject: [PATCH] move admin rack to its own file

---
 config/initializers/resque.rb | 20 +-------------------
 lib/admin_rack.rb             | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 19 deletions(-)
 create mode 100644 lib/admin_rack.rb

diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb
index 57ef069ec8..3c23cd7a01 100644
--- a/config/initializers/resque.rb
+++ b/config/initializers/resque.rb
@@ -30,24 +30,6 @@ end
 
 if AppConfig[:mount_resque_web]
   require 'resque/server'
-
-  class AdminRack
-    def initialize(app)
-      @app = app
-    end
-
-    def call(env)
-      user = env['warden'].authenticate(:scope => :user)
-      if user && user.admin?
-        @app.call(env)
-      else
-        [307, {"Location" => '/'}, self]
-      end
-    end
-
-    def each(&block)
-    end
-  end
-
+  require File.join(Rails.root, 'lib/admin_rack')
   Resque::Server.use AdminRack
 end
diff --git a/lib/admin_rack.rb b/lib/admin_rack.rb
new file mode 100644
index 0000000000..39253b3d7a
--- /dev/null
+++ b/lib/admin_rack.rb
@@ -0,0 +1,19 @@
+class AdminRack
+  def initialize(app)
+    @app = app
+  end
+
+  def call(env)
+    user = env['warden'].authenticate(:scope => :user)
+    if user && user.admin?
+      @app.call(env)
+    else
+      [307, {"Location" => '/'}, self]
+    end
+  end
+
+  def each(&block)
+  end
+end
+
+
-- 
GitLab