Permalink
Browse files

Avoid obscure &Proc.new thing

  • Loading branch information...
jonleighton committed Mar 21, 2012
1 parent f6db31e commit fd68bd23b602ef2a7b038b66e787604df9192c6d
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/scoping/named.rb
@@ -171,8 +171,8 @@ def scope_attributes? # :nodoc:
# Article.published.featured.latest_article
# Article.featured.titles
- def scope(name, scope_options = {})
- extension = Module.new(&Proc.new) if block_given?
+ def scope(name, scope_options = {}, &block)
+ extension = Module.new(&block) if block
singleton_class.send(:define_method, name) do |*args|
options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options

6 comments on commit fd68bd2

Contributor

sobrinho replied Mar 22, 2012

I remember the &Proc.new was implemented due to performance improvement.

Are we going to remove this from rails codebase?

Member

jonleighton replied Mar 22, 2012

This is evaluated at class loading time, so it is not performance critical. We don't need performance tricks in non-crticial areas of the code.

Contributor

sobrinho replied Mar 22, 2012

ok! :)

Member

drogus replied Mar 22, 2012

This is evaluated at class loading time, so it is not performance critical.
We don't need performance tricks in non-crticial areas of the code.

So you say rails apps will load even slower :trollface:

Member

jonleighton replied Mar 22, 2012

Yes, this one line is responsible for a 50% increase in Rails load time. I'm switching to Node.js!

Owner

fxn replied Mar 23, 2012

These things didn't happen with CGI.pm.

Please sign in to comment.