From 7f444a3db68c9538544f8e38c678a165a00642e3 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 20 Oct 2010 15:51:44 -0700 Subject: roll up weird method to meta programmed method --- activerecord/lib/active_record/base.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 315598fc4b..630bf7fe85 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -972,13 +972,11 @@ module ActiveRecord #:nodoc: super unless all_attributes_exists?(attribute_names) if match.scope? self.class_eval <<-METHOD, __FILE__, __LINE__ + 1 - def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args) - attributes = construct_attributes_from_arguments( # attributes = construct_attributes_from_arguments( - [:#{attribute_names.join(',:')}], args # [:user_name, :password], args - ) # ) - # - scoped(:conditions => attributes) # scoped(:conditions => attributes) - end # end + def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args) + attributes = Hash[[:#{attribute_names.join(',:')}].zip(args)] # attributes = Hash[[:user_name, :password].zip(args)] + # + scoped(:conditions => attributes) # scoped(:conditions => attributes) + end # end METHOD send(method_id, *arguments) end @@ -987,10 +985,6 @@ module ActiveRecord #:nodoc: end end - def construct_attributes_from_arguments(attribute_names, arguments) - Hash[attribute_names.zip(arguments)] - end - # Similar in purpose to +expand_hash_conditions_for_aggregates+. def expand_attribute_names_for_aggregates(attribute_names) expanded_attribute_names = [] -- cgit v1.2.3