aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-05-29 20:07:47 +0200
committerwycats <wycats@gmail.com>2010-05-29 20:08:00 +0200
commit45e60283e733a535d68d499aa20e095c905f43b0 (patch)
treeee2fbf07bfca011623c928c0b24a7783925e8f88 /railties/lib/rails/application
parent564ab4776c7e54268dc60e9a3fced7ba37657c72 (diff)
downloadrails-45e60283e733a535d68d499aa20e095c905f43b0.tar.gz
rails-45e60283e733a535d68d499aa20e095c905f43b0.tar.bz2
rails-45e60283e733a535d68d499aa20e095c905f43b0.zip
Removing Metal from Rails 3.
If you have existing Metals, you have a few options: * if your metal behaves like a middleware, add it to the middleware stack via config.middleware.use. You can use methods on the middleware stack to control exactly where it should go * if it behaves like a Rack endpoint, you can link to it in the router. This will result in more optimal routing time, and allows you to remove code in your endpoint that matches specific URLs in favor of the more powerful handling in the router itself. For the future, you can use ActionController::Metal to get a very fast controller with the ability to opt-in to specific controller features without paying the penalty of the full controller stack. Since Rails 3 is closer to Rack, the Metal abstraction is no longer needed.
Diffstat (limited to 'railties/lib/rails/application')
-rw-r--r--railties/lib/rails/application/configuration.rb7
-rw-r--r--railties/lib/rails/application/metal_loader.rb50
2 files changed, 1 insertions, 56 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 1b8af370f7..f3a326f36d 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -9,7 +9,7 @@ module Rails
attr_accessor :allow_concurrency, :cache_classes, :cache_store,
:encoding, :consider_all_requests_local, :dependency_loading,
- :filter_parameters, :log_level, :logger, :metals,
+ :filter_parameters, :log_level, :logger,
:plugins, :preload_frameworks, :reload_engines, :reload_plugins,
:secret_token, :serve_static_assets, :session_options,
:time_zone, :whiny_nils
@@ -45,10 +45,6 @@ module Rails
@middleware ||= app_middleware.merge_into(default_middleware_stack)
end
- def metal_loader
- @metal_loader ||= Rails::Application::MetalLoader.new
- end
-
def paths
@paths ||= begin
paths = super
@@ -157,7 +153,6 @@ module Rails
middleware.use('::ActionDispatch::ParamsParser')
middleware.use('::Rack::MethodOverride')
middleware.use('::ActionDispatch::Head')
- middleware.use(lambda { metal_loader.build_middleware(metals) }, :if => lambda { metal_loader.metals.any? })
end
end
end
diff --git a/railties/lib/rails/application/metal_loader.rb b/railties/lib/rails/application/metal_loader.rb
deleted file mode 100644
index 2a43fa7892..0000000000
--- a/railties/lib/rails/application/metal_loader.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'action_dispatch'
-
-module Rails
- class Application
- class MetalLoader
- attr_reader :paths, :metals
-
- def initialize
- @paths, @metals = [], []
- end
-
- def build_middleware(list=nil)
- load_metals!(list)
- self
- end
-
- def new(app)
- ActionDispatch::Cascade.new(@metals, app)
- end
-
- def name
- ActionDispatch::Cascade.name
- end
- alias :to_s :name
-
- protected
-
- def load_metals!(list)
- metals = []
- list = Array(list || :all).map(&:to_sym)
-
- paths.each do |path|
- matcher = /\A#{Regexp.escape(path)}\/(.*)\.rb\Z/
- Dir.glob("#{path}/**/*.rb").sort.each do |metal_path|
- metal = metal_path.sub(matcher, '\1').to_sym
- next unless list.include?(metal) || list.include?(:all)
- require_dependency metal.to_s
- metals << metal
- end
- end
-
- metals = metals.sort_by do |m|
- [list.index(m) || list.index(:all), m.to_s]
- end
-
- @metals = metals.map { |m| m.to_s.camelize.constantize }
- end
- end
- end
-end