Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid obscure &Proc.new thing

  • Loading branch information...
commit fd68bd23b602ef2a7b038b66e787604df9192c6d 1 parent f6db31e
@jonleighton jonleighton authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/scoping/named.rb
View
4 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

@sobrinho

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

Are we going to remove this from rails codebase?

@jonleighton
Collaborator

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.

@sobrinho

ok! :)

@drogus
Collaborator

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:

@jonleighton
Collaborator

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

@fxn
Owner

These things didn't happen with CGI.pm.

Please sign in to comment.
Something went wrong with that request. Please try again.