aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-20 15:51:44 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-20 15:51:44 -0700
commit7f444a3db68c9538544f8e38c678a165a00642e3 (patch)
treed8c86341ece00ab97f746d69fe3cc84bad0a66dd /activerecord
parentfb835fc1e2d915deed2a1a7bd6d2e14d526897df (diff)
downloadrails-7f444a3db68c9538544f8e38c678a165a00642e3.tar.gz
rails-7f444a3db68c9538544f8e38c678a165a00642e3.tar.bz2
rails-7f444a3db68c9538544f8e38c678a165a00642e3.zip
roll up weird method to meta programmed method
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb16
1 files changed, 5 insertions, 11 deletions
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 = []