From ad6be0876271f86e76c89645a0106b85c9d77ad7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 22 Jun 2010 23:51:28 +0200 Subject: Made Engine valid rack app with its own middleware stack --- railties/lib/rails/engine/configurable.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/engine/configurable.rb') diff --git a/railties/lib/rails/engine/configurable.rb b/railties/lib/rails/engine/configurable.rb index 9a370f0abb..0af01cace2 100644 --- a/railties/lib/rails/engine/configurable.rb +++ b/railties/lib/rails/engine/configurable.rb @@ -3,10 +3,12 @@ module Rails module Configurable def self.included(base) base.extend ClassMethods + base.private_class_method :new end module ClassMethods delegate :middleware, :root, :paths, :to => :config + delegate :call, :to => :instance def config @config ||= Engine::Configuration.new(find_root_with_flag("lib")) @@ -15,6 +17,15 @@ module Rails def inherited(base) raise "You cannot inherit from a Rails::Engine child" end + + def instance + @instance ||= new + end + + def endpoint(endpoint = nil) + @endpoint = endpoint if endpoint + @endpoint + end end def config @@ -22,4 +33,4 @@ module Rails end end end -end \ No newline at end of file +end -- cgit v1.2.3 From 3939d6bb51fc36ac863f0e4766ed8d87fad98297 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 8 Jul 2010 12:07:25 +0200 Subject: Removed ActionDispatch::Static, but left empty MiddlewareStack to unify app method between Engine and Application --- railties/lib/rails/engine/configurable.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'railties/lib/rails/engine/configurable.rb') diff --git a/railties/lib/rails/engine/configurable.rb b/railties/lib/rails/engine/configurable.rb index 0af01cace2..e668911913 100644 --- a/railties/lib/rails/engine/configurable.rb +++ b/railties/lib/rails/engine/configurable.rb @@ -21,11 +21,6 @@ module Rails def instance @instance ||= new end - - def endpoint(endpoint = nil) - @endpoint = endpoint if endpoint - @endpoint - end end def config -- cgit v1.2.3 From 32a5b49911b88e8e410583d382e8253004abce50 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 19 Jul 2010 17:53:14 +0200 Subject: Move singleton pattern to Railtie and remove Engine::Configurable and Application::Configurable in favor of unified Railtie::Configurable --- railties/lib/rails/engine/configurable.rb | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 railties/lib/rails/engine/configurable.rb (limited to 'railties/lib/rails/engine/configurable.rb') diff --git a/railties/lib/rails/engine/configurable.rb b/railties/lib/rails/engine/configurable.rb deleted file mode 100644 index e668911913..0000000000 --- a/railties/lib/rails/engine/configurable.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Rails - class Engine - module Configurable - def self.included(base) - base.extend ClassMethods - base.private_class_method :new - end - - module ClassMethods - delegate :middleware, :root, :paths, :to => :config - delegate :call, :to => :instance - - def config - @config ||= Engine::Configuration.new(find_root_with_flag("lib")) - end - - def inherited(base) - raise "You cannot inherit from a Rails::Engine child" - end - - def instance - @instance ||= new - end - end - - def config - self.class.config - end - end - end -end -- cgit v1.2.3