Permalink
Browse files

delete unused code

Now that we merge trees from the top down, we don't need to search
through the whole tree for particular nodes, just walk it and merge.
  • Loading branch information...
1 parent 223082e commit ff5f328bdfdd3dffd31bd74adac9d1e6e7f241fd @tenderlove tenderlove committed Oct 10, 2013
@@ -61,30 +61,10 @@ def initialize(base, associations, joins)
build tree, @join_root, Arel::InnerJoin
end
- def graft(associations)
@radar

radar Dec 18, 2013

Contributor

We were using this method in Ransack 😢

Is there an alternative to this now?

@D1plo1d

D1plo1d May 28, 2014

Contributor

This is an issue with Squeel as well :(

- associations.reject { |join_node|
- find_node join_node
- }.each { |join_node|
- parent = find_node(join_node.parent) || join_root
- reflection = join_node.reflection
- type = join_node.join_type
-
- next if parent.children.find { |j| j.reflection == reflection }
- build_scalar reflection, parent, type
- }
- self
- end
-
def reflections
join_root.drop(1).map!(&:reflection)
end
- def outer_joins
- nodes = join_root.drop 1
- nodes.each { |n| n.join_type = Arel::OuterJoin }
- nodes
- end
-
def merge_outer_joins!(other)
left = join_root
right = other.join_root
@@ -148,26 +128,6 @@ def deep_copy(parent, node)
dup
end
- def find_node(target_node)
- stack = target_node.parents << target_node
-
- left = [join_root]
- right = stack.shift
-
- loop {
- match = left.find { |l| l.match? right }
-
- if match
- return match if stack.empty?
-
- left = match.children
- right = stack.shift
- else
- return nil
- end
- }
- end
-
def remove_duplicate_results!(base, records, associations)
associations.each do |node|
reflection = base.reflect_on_association(node.name)
@@ -40,16 +40,6 @@ def match?(other)
self.class == other.class
end
- def parents
- parents = []
- node = parent
- while node
- parents.unshift node
- node = node.parent
- end
- parents
- end
-
def each(&block)
yield self
children.each { |child| child.each(&block) }

0 comments on commit ff5f328

Please sign in to comment.