Sha256: f06d30f8e9a519524308438e93e7024f49c4252a27d79c6b87ea344057026665
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
require 'active_support/ordered_hash' module Rails module Rack class Metal NotFoundResponse = [404, {}, []].freeze NotFound = lambda { NotFoundResponse } 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 = {} metal_glob.each do |glob| Dir[glob].sort.map do |file| file = file.match(matcher)[1] all_metals[file.camelize] = file end 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) @app = app @metals = ActiveSupport::OrderedHash.new self.class.metals.each { |app| @metals[app] = true } freeze end def call(env) @metals.keys.each do |app| result = app.call(env) return result unless result[0].to_i == 404 end @app.call(env) end end end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
webroar-0.2.2 | src/admin_panel/vendor/rails/railties/lib/rails/rack/metal.rb |
radiant-0.8.0 | vendor/rails/railties/lib/rails/rack/metal.rb |
rails-2.3.2 | lib/rails/rack/metal.rb |