lib/neo4j/active_node/has_n.rb in neo4j-5.2.10 vs lib/neo4j/active_node/has_n.rb in neo4j-5.2.11
- old
+ new
@@ -299,23 +299,22 @@
def define_has_many_methods(name)
define_method(name) do |node = nil, rel = nil, options = {}|
# return [].freeze unless self._persisted_obj
- if node.is_a?(Hash)
- options = node
- node = nil
- end
+ options, node = node, nil if node.is_a?(Hash)
association_proxy(name, {node: node, rel: rel, source_object: self, labels: options[:labels]}.merge!(options))
end
define_has_many_setter(name)
define_has_many_id_methods(name)
define_class_method(name) do |node = nil, rel = nil, options = {}|
+ options, node = node, nil if node.is_a?(Hash)
+
association_proxy(name, {node: node, rel: rel, labels: options[:labels]}.merge!(options))
end
end
def define_has_many_setter(name)
@@ -350,10 +349,12 @@
define_has_one_setter(name)
define_has_one_id_methods(name)
define_class_method(name) do |node = nil, rel = nil, options = {}|
+ options, node = node, nil if node.is_a?(Hash)
+
association_proxy(name, {node: node, rel: rel, labels: options[:labels]}.merge!(options))
end
end
def define_has_one_id_methods(name)
@@ -372,13 +373,10 @@
def define_has_one_getter(name)
define_method(name) do |node = nil, rel = nil, options = {}|
return nil unless self._persisted_obj
- if node.is_a?(Hash)
- options = node
- node = nil
- end
+ options, node = node, nil if node.is_a?(Hash)
# Return all results if a variable-length relationship length was given
results = association_proxy(name, {node: node, rel: rel}.merge!(options))
if options[:rel_length] && !options[:rel_length].is_a?(Fixnum)
results