lib/neo4j/active_node/has_n.rb in neo4j-8.1.5 vs lib/neo4j/active_node/has_n.rb in neo4j-8.2.1
- old
+ new
@@ -36,10 +36,14 @@
def each(&block)
result_nodes.each(&block)
end
+ def each_rel(&block)
+ rels.each(&block)
+ end
+
# .count always hits the database
def_delegator :@query_proxy, :count
def length
@deferred_objects.length + @enumerable.length
@@ -90,12 +94,21 @@
def cache_result(result)
@cached_result = result
@enumerable = (@cached_result || @query_proxy)
end
- def add_to_cache(object)
+ def init_cache
+ @cached_rels ||= []
@cached_result ||= []
- @cached_result << object
+ end
+
+ def add_to_cache(object, rel = nil)
+ @cached_rels << rel if rel
+ (@cached_result ||= []) << object
+ end
+
+ def rels
+ @cached_rels || super
end
def cache_query_proxy_result
(result_cache_proc_cache || @query_proxy).to_a.tap { |result| cache_result(result) }
end