Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

we have no need for the ASSOCIATION_METHODS constant

  • Loading branch information...
commit e4f0fbd994ab0c333e615be68a8d40593c7058e3 1 parent a258c27
@jonleighton jonleighton authored
View
11 activerecord/lib/active_record/relation.rb
@@ -6,9 +6,12 @@ module ActiveRecord
# = Active Record Relation
class Relation
JoinOperation = Struct.new(:relation, :join_class, :on)
- ASSOCIATION_METHODS = [:includes, :eager_load, :preload]
- MULTI_VALUE_METHODS = [:select, :group, :order, :joins, :where, :having, :bind, :references]
- SINGLE_VALUE_METHODS = [:limit, :offset, :lock, :readonly, :from, :reordering, :reverse_order, :uniq]
+
+ MULTI_VALUE_METHODS = [:includes, :eager_load, :preload, :select, :group,
+ :order, :joins, :where, :having, :bind, :references]
+
+ SINGLE_VALUE_METHODS = [:limit, :offset, :lock, :readonly, :from, :reordering,
+ :reverse_order, :uniq]
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain, Delegation
@@ -25,7 +28,7 @@ def initialize(klass, table)
@default_scoped = false
SINGLE_VALUE_METHODS.each {|v| instance_variable_set(:"@#{v}_value", nil)}
- (ASSOCIATION_METHODS + MULTI_VALUE_METHODS).each {|v| instance_variable_set(:"@#{v}_values", [])}
+ MULTI_VALUE_METHODS.each {|v| instance_variable_set(:"@#{v}_values", [])}
@extensions = []
@create_with_value = {}
end
View
2  activerecord/lib/active_record/relation/merger.rb
@@ -23,7 +23,7 @@ def merge
private
def merge_multi_values
- values = Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS - [:where, :order, :bind]
+ values = Relation::MULTI_VALUE_METHODS - [:where, :order, :bind]
values.each do |method|
value = other.send(:"#{method}_values")
View
4 activerecord/lib/active_record/relation/spawn_methods.rb
@@ -26,7 +26,7 @@ def except(*skips)
result = self.class.new(@klass, table)
result.default_scoped = default_scoped
- ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) - skips).each do |method|
+ (Relation::MULTI_VALUE_METHODS - skips).each do |method|
result.send(:"#{method}_values=", send(:"#{method}_values"))
end
@@ -51,7 +51,7 @@ def only(*onlies)
result = self.class.new(@klass, table)
result.default_scoped = default_scoped
- ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) & onlies).each do |method|
+ (Relation::MULTI_VALUE_METHODS & onlies).each do |method|
result.send(:"#{method}_values=", send(:"#{method}_values"))
end
View
9 activerecord/test/cases/relation_test.rb
@@ -26,13 +26,6 @@ def test_initialize_single_values
end
end
- def test_initialize_association_methods
- relation = Relation.new :a, :b
- Relation::ASSOCIATION_METHODS.each do |method|
- assert_equal [], relation.send("#{method}_values"), method.to_s
- end
- end
-
def test_multi_value_initialize
relation = Relation.new :a, :b
Relation::MULTI_VALUE_METHODS.each do |method|
@@ -146,7 +139,7 @@ def relation
@relation ||= Relation.new :a, :b
end
- (Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS - [:references]).each do |method|
+ (Relation::MULTI_VALUE_METHODS - [:references]).each do |method|
test "##{method}!" do
assert relation.public_send("#{method}!", :foo).equal?(relation)
assert_equal [:foo], relation.public_send("#{method}_values")
Please sign in to comment.
Something went wrong with that request. Please try again.