neo4j 5.2.13 → 5.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/neo4j/active_node/persistence.rb +1 -2
- data/lib/neo4j/active_rel.rb +4 -7
- data/lib/neo4j/active_rel/related_node.rb +27 -1
- data/lib/neo4j/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f213593268bdbcf3ca457f605bf2df1f86b7dc01
|
4
|
+
data.tar.gz: 3daa420d673284f5ceba6b259725713271925783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5206d87f81b88acde44706e8e292cc0c80fdfba49f3cc1b2ebe1d2041f1a57f8b7e96b3125dcbbbe8acdf81a855c055d4b4a8545c372e7266050022b80ad81df
|
7
|
+
data.tar.gz: 30555f314d1f1aaabd691dc841853ffa04e9d65e337dc7930e1b20ff00aaa37afa7431a3a4c1e07e3a488c13c57db3bd986899a4096e21a475e8e5306fc26f6a
|
@@ -130,9 +130,8 @@ module Neo4j::ActiveNode
|
|
130
130
|
|
131
131
|
def find_or_create(find_attributes, set_attributes = {})
|
132
132
|
on_create_attributes = set_attributes.merge(on_create_props(find_attributes))
|
133
|
-
on_match_attributes = set_attributes.merge(on_match_props)
|
134
133
|
neo4j_session.query.merge(n: {self.mapped_label_names => find_attributes})
|
135
|
-
.on_create_set(n: on_create_attributes)
|
134
|
+
.on_create_set(n: on_create_attributes)
|
136
135
|
.pluck(:n).first
|
137
136
|
end
|
138
137
|
|
data/lib/neo4j/active_rel.rb
CHANGED
@@ -27,16 +27,13 @@ module Neo4j
|
|
27
27
|
attribute_descriptions = attribute_pairs.join(', ')
|
28
28
|
separator = ' ' unless attribute_descriptions.empty?
|
29
29
|
|
30
|
-
cypher_representation = "#{node_cypher_representation(
|
30
|
+
cypher_representation = "#{node_cypher_representation(:from)}-[:#{type}]->#{node_cypher_representation(:to)}"
|
31
31
|
"#<#{self.class.name} #{cypher_representation}#{separator}#{attribute_descriptions}>"
|
32
32
|
end
|
33
33
|
|
34
|
-
def node_cypher_representation(
|
35
|
-
|
36
|
-
|
37
|
-
labels = ':' + node_class.mapped_label_names.join(':')
|
38
|
-
|
39
|
-
"(#{labels} {#{id_name}: #{node.id.inspect}})"
|
34
|
+
def node_cypher_representation(direction)
|
35
|
+
node = send(:"#{direction}_node")
|
36
|
+
node.cypher_representation(self.class.send(:"#{direction}_class"))
|
40
37
|
end
|
41
38
|
|
42
39
|
def neo4j_obj
|
@@ -4,6 +4,7 @@ module Neo4j::ActiveRel
|
|
4
4
|
# will result in a query to load the node if the node is not already loaded.
|
5
5
|
class RelatedNode
|
6
6
|
class InvalidParameterError < StandardError; end
|
7
|
+
class UnsetRelatedNodeError < StandardError; end
|
7
8
|
|
8
9
|
# ActiveRel's related nodes can be initialized with nothing, an integer, or a fully wrapped node.
|
9
10
|
#
|
@@ -30,20 +31,41 @@ module Neo4j::ActiveRel
|
|
30
31
|
|
31
32
|
# Loads a node from the database or returns the node if already laoded
|
32
33
|
def loaded
|
34
|
+
fail NilRelatedNodeError, 'Node not set, cannot load' if @node.nil?
|
33
35
|
@node = @node.respond_to?(:neo_id) ? @node : Neo4j::Node.load(@node)
|
34
36
|
end
|
35
37
|
|
38
|
+
# @param [String, Symbol, Array] clazz An alternate label to use in the event the node is not present or loaded
|
39
|
+
def cypher_representation(clazz)
|
40
|
+
case
|
41
|
+
when !set?
|
42
|
+
"(#{formatted_label_list(clazz)})"
|
43
|
+
when set? && !loaded?
|
44
|
+
"(Node with neo_id #{@node})"
|
45
|
+
else
|
46
|
+
node_class = self.class
|
47
|
+
id_name = node_class.id_property_name
|
48
|
+
labels = ':' + node_class.mapped_label_names.join(':')
|
49
|
+
|
50
|
+
"(#{labels} {#{id_name}: #{@node.id.inspect}})"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
36
54
|
# @return [Boolean] indicates whether a node has or has not been fully loaded from the database
|
37
55
|
def loaded?
|
38
56
|
@node.respond_to?(:neo_id)
|
39
57
|
end
|
40
58
|
|
59
|
+
def set?
|
60
|
+
!@node.nil?
|
61
|
+
end
|
62
|
+
|
41
63
|
def method_missing(*args, &block)
|
42
64
|
loaded.send(*args, &block)
|
43
65
|
end
|
44
66
|
|
45
67
|
def respond_to_missing?(method_name, include_private = false)
|
46
|
-
loaded if @node.is_a?(
|
68
|
+
loaded if @node.is_a?(Numeric)
|
47
69
|
@node.respond_to?(method_name) ? true : super
|
48
70
|
end
|
49
71
|
|
@@ -53,6 +75,10 @@ module Neo4j::ActiveRel
|
|
53
75
|
|
54
76
|
private
|
55
77
|
|
78
|
+
def formatted_label_list(list)
|
79
|
+
list.is_a?(Array) ? list.join(' || ') : list
|
80
|
+
end
|
81
|
+
|
56
82
|
def valid_node_param?(node)
|
57
83
|
node.nil? || node.is_a?(Integer) || node.respond_to?(:neo_id)
|
58
84
|
end
|
data/lib/neo4j/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Brian Underwood, Chris Grigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|