aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-06-22 23:51:28 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:03 +0200
commitad6be0876271f86e76c89645a0106b85c9d77ad7 (patch)
treefcbe3b9d4e0bd5d7b12f6e293e1077b4893a9320 /railties/lib/rails/engine.rb
parentf7af75976a9117aa1cb294114af4f99a1d28f1cd (diff)
downloadrails-ad6be0876271f86e76c89645a0106b85c9d77ad7.tar.gz
rails-ad6be0876271f86e76c89645a0106b85c9d77ad7.tar.bz2
rails-ad6be0876271f86e76c89645a0106b85c9d77ad7.zip
Made Engine valid rack app with its own middleware stack
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r--railties/lib/rails/engine.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 555bc9dbc8..f8a33ffe24 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -140,6 +140,19 @@ module Rails
end
end
+ def app
+ raise "You can't use Engine as rack application without providing valid rack endpoint" unless endpoint
+ @app ||= config.middleware.build(endpoint)
+ end
+
+ def endpoint
+ self.class.endpoint
+ end
+
+ def call(env)
+ app.call(env)
+ end
+
# Add configured load paths to ruby load paths and remove duplicates.
initializer :set_load_path, :before => :bootstrap_hook do
_all_load_paths.reverse_each do |path|