Merge pull request #25352 from Shopify/optimized-delegate

Replace Kernel#caller by the faster Kernel#caller_locations
This commit is contained in:
Rafael França 2016-06-10 13:04:50 -04:00 committed by GitHub
commit 7fd477c0f5

@ -164,8 +164,8 @@ def delegate(*methods, to: nil, prefix: nil, allow_nil: nil)
''
end
file, line = caller(1, 1).first.split(':'.freeze, 2)
line = line.to_i
location = caller_locations(1, 1).first
file, line = location.path, location.lineno
to = to.to_s
to = "self.#{to}" if DELEGATION_RESERVED_METHOD_NAMES.include?(to)