From fd68bd23b602ef2a7b038b66e787604df9192c6d Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 21 Mar 2012 20:37:14 +0000 Subject: [PATCH] Avoid obscure &Proc.new thing --- activerecord/lib/active_record/scoping/named.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb index 20c8e4b0f7..2f266eff79 100644 --- a/activerecord/lib/active_record/scoping/named.rb +++ b/activerecord/lib/active_record/scoping/named.rb @@ -171,8 +171,8 @@ module ActiveRecord # 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