aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-23 14:43:17 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-23 14:43:32 -0700
commitf38b5444428f418c4e6377bbb40d7518ea0c61a7 (patch)
tree21da7b1c7752c31f17fefb1ef6635e221ed8ec78 /activerecord/lib/active_record/relation
parentb017562382e1c43655eec3456d2a78c1d4407952 (diff)
downloadrails-f38b5444428f418c4e6377bbb40d7518ea0c61a7.tar.gz
rails-f38b5444428f418c4e6377bbb40d7518ea0c61a7.tar.bz2
rails-f38b5444428f418c4e6377bbb40d7518ea0c61a7.zip
add a specific factory method rather than using new
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/delegation.rb6
-rw-r--r--activerecord/lib/active_record/relation/merger.rb2
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb2
3 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb
index 8d6740246c..7ed65a548c 100644
--- a/activerecord/lib/active_record/relation/delegation.rb
+++ b/activerecord/lib/active_record/relation/delegation.rb
@@ -73,10 +73,8 @@ module ActiveRecord
module ClassMethods # :nodoc:
@@subclasses = ThreadSafe::Cache.new(:initial_capacity => 2)
- def new(klass, *args)
- relation = relation_class_for(klass).allocate
- relation.__send__(:initialize, klass, *args)
- relation
+ def create(klass, *args)
+ relation_class_for(klass).new(klass, *args)
end
# This doesn't have to be thread-safe. relation_class_for guarantees that this will only be
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index da13152e01..c08158d38b 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -22,7 +22,7 @@ module ActiveRecord
# build a relation to merge in rather than directly merging
# the values.
def other
- other = Relation.new(relation.klass, relation.table)
+ other = Relation.create(relation.klass, relation.table)
hash.each { |k, v|
if k == :joins
if Hash === v
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index c63ae9c9fb..2552cbd234 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -64,7 +64,7 @@ module ActiveRecord
private
def relation_with(values) # :nodoc:
- result = Relation.new(klass, table, values)
+ result = Relation.create(klass, table, values)
result.extend(*extending_values) if extending_values.any?
result
end