diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-08 15:42:55 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-08 15:42:55 -0200 |
commit | d428242c865847f86512b671428f556ab88cc21d (patch) | |
tree | 89de1c2693dab294fc55a3c2b9387a975c2700ad /actionpack | |
parent | 7fb809c03359cb4bc80204a557abdb20bbd8dc25 (diff) | |
download | rails-d428242c865847f86512b671428f556ab88cc21d.tar.gz rails-d428242c865847f86512b671428f556ab88cc21d.tar.bz2 rails-d428242c865847f86512b671428f556ab88cc21d.zip |
Only check that it is a Rails application once
Also avoid using try since is_a? is faster for this case.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index f07a4aa674..b9e916078c 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -579,14 +579,15 @@ module ActionDispatch raise "A rack application must be specified" unless path - options[:as] ||= app_name(app) + rails_app = rails_app? app + options[:as] ||= app_name(app, rails_app) target_as = name_for_action(options[:as], path) options[:via] ||= :all match(path, options.merge(:to => app, :anchor => false, :format => false)) - define_generate_prefix(app, target_as) if rails_app?(app) + define_generate_prefix(app, target_as) if rails_app self end @@ -611,10 +612,11 @@ module ActionDispatch app.is_a?(Class) && app < Rails::Railtie end - def app_name(app) - if rails_app?(app) + def app_name(app, rails_app) + if rails_app app.railtie_name - elsif class_name = app.try(:name) + elsif app.is_a?(Class) + class_name = app.name ActiveSupport::Inflector.underscore(class_name).tr("/", "_") end end |