Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

yield > block.call

  • Loading branch information...
commit 3a967806ad9cb8e319edf90a88dae1fb1eb35935 1 parent 15dab0d
@fxn fxn authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/explain.rb
View
6 activerecord/lib/active_record/explain.rb
@@ -29,7 +29,7 @@ def logging_query_plan(&block) # :nodoc:
Thread.current[LOGGING_QUERY_PLAN] = false
end
else
- block.call
+ yield

You may even remove &block from signature and use Proc.new instead of &block in a place where it's passed through. Of course, that would make the code more unobvious, but will avoid expensive implicit to_proc in half of the cases.

Just a thought, relevant to "yield > block.call".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
end
@@ -43,7 +43,7 @@ def ignore_explain_notification?(payload) # :nodoc:
# Collects all queries executed while the passed block runs. Returns an
# array with three elements, the result of the block, the strings with the
# queries, and their respective bindings.
- def collecting_sqls_for_explain(&block) # :nodoc:
+ def collecting_sqls_for_explain # :nodoc:
sqls = []
binds = []
callback = lambda do |*args|
@@ -56,7 +56,7 @@ def collecting_sqls_for_explain(&block) # :nodoc:
result = nil
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
- result = block.call
+ result = yield
end
[result, sqls, binds]
Please sign in to comment.
Something went wrong with that request. Please try again.