lib/rack/app/cli/fetcher.rb in rack-app-5.0.0 vs lib/rack/app/cli/fetcher.rb in rack-app-5.1.0

- old
+ new

@@ -10,24 +10,23 @@ end end def rack_app + @rack_app ||= (server_based_lookup || rack_app_with_most_endpoints) + end - server = Rack::App::CLI::Fetcher::Server.new(:config => 'config.ru') + protected - app = server.app + def server_based_lookup + Rack::App::CLI::Fetcher::Server.new(:config => 'config.ru').get_rack_app + end - until app.is_a?(Class) && app <= Rack::App - app.instance_variables.each do |ivar| - value = app.instance_variable_get(ivar) - if value.respond_to?(:call) and not [Method, Proc, UnboundMethod].include?(value.class) - app = value - end - end - end - - app - + def rack_app_with_most_endpoints + ObjectSpace.each_object(Class).select{|klass| + klass < Rack::App + }.uniq.sort_by{ |rack_app| + rack_app.router.endpoints.length + }.last end end