From f96b19b6da582bc99dde3f74aeee6ff68353d7c9 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 23 Jul 2015 07:51:28 +1000 Subject: Remove check for caller_locations in Rails::Engine This is no longer necessary, as the minimum version requirement for Ruby is 2.2.2, and the `caller_locations` feature was added in Ruby 2.0.0. Since Rails no longer supports pre 2.0 versions of Ruby, there is no need to check first if the Kernel does respond to `caller_locations`. The answer is: yes it does. --- railties/lib/rails/engine.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 1dede32dd4..64c15f8f89 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -357,12 +357,7 @@ module Rails Rails::Railtie::Configuration.eager_load_namespaces << base base.called_from = begin - call_stack = if Kernel.respond_to?(:caller_locations) - caller_locations.map { |l| l.absolute_path || l.path } - else - # Remove the line number from backtraces making sure we don't leave anything behind - caller.map { |p| p.sub(/:\d+.*/, '') } - end + call_stack = caller_locations.map { |l| l.absolute_path || l.path } File.dirname(call_stack.detect { |p| p !~ %r[railties[\w.-]*/lib/rails|rack[\w.-]*/lib/rack] }) end -- cgit v1.2.3