From 8c3a54366435eebc2c8aa63b63e1349ce74a7b38 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 16 Dec 2008 13:11:51 -0600 Subject: Introduce Rails Metal # app/metal/poller.rb class Poller < Rails::Rack::Metal def call(env) if env["PATH_INFO"] =~ /^\/poller/ [200, {"Content-Type" => "application/json"}, Message.recent.to_json] else super end end end * There is a generator to help you get started `script/generate metal poller` * Also, metal bits can be ran standalone with rackup `rackup app/metal/poller.rb` --- railties/lib/initializer.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 56e8ce95ab..f22e34c7dc 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -155,6 +155,8 @@ module Rails initialize_framework_settings initialize_framework_views + initialize_metal + add_support_load_paths load_gems @@ -533,6 +535,12 @@ Run `rake gems:install` to install the missing gems. end end + def initialize_metal + Dir["#{configuration.root_path}/app/metal/*.rb"].each do |file| + configuration.middleware.use(File.basename(file, '.rb').camelize) + end + end + # Initializes framework-specific settings for each of the loaded frameworks # (Configuration#frameworks). The available settings map to the accessors # on each of the corresponding Base classes. @@ -915,6 +923,7 @@ Run `rake gems:install` to install the missing gems. # Followed by the standard includes. paths.concat %w( app + app/metal app/models app/controllers app/helpers @@ -933,6 +942,7 @@ Run `rake gems:install` to install the missing gems. def default_eager_load_paths %w( + app/metal app/models app/controllers app/helpers -- cgit v1.2.3