Permalink
Browse files

add some convenient methods for avoiding array allocations

  • Loading branch information...
1 parent 752a06e commit 0cfb1de4583b5926bbb10de39d80d8537a7e6482 @tenderlove tenderlove committed Oct 9, 2013
@@ -76,17 +76,17 @@ def graft(*associations)
end
def reflections
- join_root.drop(1).map(&:reflection)
+ join_root.drop(1).map!(&:reflection)
end
def join_relation(relation)
- join_root.drop(1).inject(relation) do |rel,association|
+ join_root.inject(relation) do |rel,association|
association.join_relation(rel)
end
end
def join_constraints
- join_root.drop(1).flat_map(&:join_constraints)
+ join_root.flat_map(&:join_constraints)
end
def columns
@@ -29,6 +29,9 @@ def initialize(base_klass, parent)
@children = []
end
+ def join_constraints; []; end
+ def join_relation(rel); rel; end
+
def name
reflection.name
end

0 comments on commit 0cfb1de

Please sign in to comment.