diff options
author | Simon Jefford <simon.jefford@gmail.com> | 2009-03-03 12:39:19 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-03-03 12:39:19 -0600 |
commit | 4d4d2c3896ed5a5d74da833c5c3132f406f4eab7 (patch) | |
tree | 82245e9e41fb058e4d9a581a37631c3affcb2520 /railties/lib/rails | |
parent | 818556ec4f237b19f28fdecdfe6037718cceba37 (diff) | |
download | rails-4d4d2c3896ed5a5d74da833c5c3132f406f4eab7.tar.gz rails-4d4d2c3896ed5a5d74da833c5c3132f406f4eab7.tar.bz2 rails-4d4d2c3896ed5a5d74da833c5c3132f406f4eab7.zip |
Enhanced Rails Metal - the load order of metals can now be configured [#2057 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/rack/metal.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb index 8dac992ef2..bce59f4c78 100644 --- a/railties/lib/rails/rack/metal.rb +++ b/railties/lib/rails/rack/metal.rb @@ -8,16 +8,26 @@ module Rails cattr_accessor :metal_paths self.metal_paths = ["#{Rails.root}/app/metal"] + cattr_accessor :requested_metals def self.metals matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/ metal_glob = metal_paths.map{ |base| "#{base}/**/*.rb" } + all_metals = {} Dir[*metal_glob].sort.map do |file| - path = file.match(matcher)[1] - require path - path.classify.constantize + file = file.match(matcher)[1] + all_metals[file.classify] = file end + + load_list = requested_metals || all_metals.keys + + load_list.map do |requested_metal| + if metal = all_metals[requested_metal] + require metal + requested_metal.constantize + end + end.compact end def initialize(app) |