Permalink
Browse files

hide join_parts internals from other classes

  • Loading branch information...
1 parent 84499eb commit ebe4f80512f5c13accf1885759ac2a38723b1c3d @tenderlove tenderlove committed Oct 8, 2013
@@ -41,7 +41,7 @@ def initialize(base, associations, joins)
def graft(*associations)
associations.each do |association|
join_associations.detect {|a| association == a} ||
- build(association.reflection.name, association.find_parent_in(self) || join_base, association.join_type)
+ build(association.reflection.name, find_parent_part(association.parent) || join_base, association.join_type)
end
self
end
@@ -50,10 +50,6 @@ def join_associations
join_parts.drop 1
end
- def join_base
- join_parts.first
- end
-
def join_relation(relation)
join_associations.inject(relation) do |rel,association|
association.join_relation(rel)
@@ -86,7 +82,22 @@ def instantiate(result_set)
records
end
- protected
+ private
+
+ def find_parent_part(parent)
+ join_parts.detect do |join_part|
+ case parent
+ when JoinBase
+ parent.base_klass == join_part.base_klass
+ else
+ parent == join_part
+ end
+ end
+ end
+
+ def join_base
+ join_parts.first
+ end
def remove_duplicate_results!(base, records, associations)
case associations
@@ -44,17 +44,6 @@ def ==(other)
other.parent == parent
end
- def find_parent_in(other_join_dependency)
- other_join_dependency.join_parts.detect do |join_part|
- case parent
- when JoinBase
- parent.base_klass == join_part.base_klass
- else
- parent == join_part
- end
- end
- end
-
def join_constraints
joins = []
tables = @tables.dup

0 comments on commit ebe4f80

Please sign in to comment.