From 99492bad885aa0ee44c770e2c61ad36c3058c697 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 29 Aug 2008 21:12:37 +0200 Subject: Use a set for the named scope methods not a big regexp. --- activerecord/lib/active_record/named_scope.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/named_scope.rb') diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index b9b7eb5f00..570416d4e0 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -101,9 +101,9 @@ module ActiveRecord class Scope attr_reader :proxy_scope, :proxy_options - + NON_DELEGATE_METHODS = %w(nil? send object_id class extend find count sum average maximum minimum paginate first last empty? any? respond_to?).to_set [].methods.each do |m| - unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty\?|any\?|respond_to\?)/ + unless m =~ /^__/ || NON_DELEGATE_METHODS.include?(m) delegate m, :to => :proxy_found end end -- cgit v1.2.3