neo4j-core 3.0.0.alpha.4 → 3.0.0.alpha.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7ad8a3566b38431c3fb2b4420b3918f32bb9fdf
4
- data.tar.gz: 5e5e6af23ddd35f2b734f8e481f9fdd4a602ade4
3
+ metadata.gz: 0b8d26b2492ff2888f2c2606aeee0ce9255a1258
4
+ data.tar.gz: f7fc8825fd0e49e7fa76165fef2c9e2610cb206e
5
5
  SHA512:
6
- metadata.gz: 1c27c255130a0cd822b5853913246e0a3b9d12e83ffd74d9793923b42611890ab053e872278daa8547623e550d1d9e45143ab7256505745b646e18ce9c5c675b
7
- data.tar.gz: 527b493adbb69deee8f9ebb490e9dbf7f2e3d9d038024cd3cf0b76d715134534440960fd4b97a7ffda4045ad6c929ba9569cabae55d33e410f3b1c71880fdc4b
6
+ metadata.gz: 54c8b882ea08e8c2e9ea63a5c641e17d5ea84b247a1fb5c6b3b345bb7fb449ff03ee608a80639f82c2e57aa763a15286f94b29b2d895f9ec1eb0dc80fb2a9bde
7
+ data.tar.gz: 119921f81ce0918cc3273db1cccc89a50c5543024d2d0b80bacaeb36438541785579a293da8ca14839ecbd0dcfea6b44ba48958ca1ad4eb370883832ec443bb7
data/lib/neo4j/node.rb CHANGED
@@ -1,16 +1,21 @@
1
1
  module Neo4j
2
2
 
3
- # A module that allows plugins to register wrappers around Neo4j::Node objects
4
- module Wrapper
5
- # Used by Neo4j::NodeMixin to wrap nodes
6
- def wrapper
7
- self
8
- end
9
- end
10
-
11
3
  # The base class for both the Embedded and Server Neo4j Node
12
4
  # Notice this class is abstract and can't be instantiated
13
5
  class Node
6
+
7
+ # A module that allows plugins to register wrappers around Neo4j::Node objects
8
+ module Wrapper
9
+ # Used by Neo4j::NodeMixin to wrap nodes
10
+ def wrapper
11
+ self
12
+ end
13
+
14
+ def neo4j_obj
15
+ self
16
+ end
17
+ end
18
+
14
19
  include EntityEquality
15
20
  include Wrapper
16
21
  include PropertyContainer
@@ -123,6 +128,10 @@ module Neo4j
123
128
  raise 'not implemented'
124
129
  end
125
130
 
131
+ def _rel(spec = {})
132
+ raise 'not implemented'
133
+ end
134
+
126
135
  # Returns true or false if there is one or more relationships
127
136
  # Same as `!! #rel()`
128
137
  def rel?(spec = {})
@@ -10,8 +10,17 @@ module Neo4j
10
10
  # i.e. start_node, end_node and other_node are guaranteed to always return valid, non-nil nodes.
11
11
  class Relationship
12
12
 
13
+ # A module that allows plugins to register wrappers around Neo4j::Node objects
14
+ module Wrapper
15
+ # Used by Neo4j::NodeMixin to wrap nodes
16
+ def wrapper
17
+ self
18
+ end
19
+ end
20
+
13
21
  include PropertyContainer
14
22
  include EntityEquality
23
+ include Wrapper
15
24
 
16
25
  # @abstract
17
26
  def start_node
@@ -65,6 +74,11 @@ module Neo4j
65
74
  # @return [Neo4j::Node] the other node wrapper
66
75
  # @see #_other_node
67
76
  def other_node(node)
77
+ _other_node(node.neo4j_obj).wrapper
78
+ end
79
+
80
+ # Same as #other_node but can return a none wrapped node
81
+ def _other_node(node)
68
82
  if node == start_node
69
83
  return end_node
70
84
  elsif node == end_node
@@ -74,6 +88,7 @@ module Neo4j
74
88
  end
75
89
  end
76
90
 
91
+
77
92
  class << self
78
93
  def load(neo_id, session = Neo4j::Session.current)
79
94
  session.load_relationship(neo_id)
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = "3.0.0.alpha.4"
3
+ VERSION = "3.0.0.alpha.5"
4
4
  end
5
5
  end
@@ -9,7 +9,7 @@ module Neo4j::Embedded
9
9
  end
10
10
 
11
11
  def each(&block)
12
- @node._rels(@match).each {|r| block.call(r)}
12
+ @node._rels(@match).each {|r| block.call(r.wrapper)}
13
13
  end
14
14
  tx_methods :each
15
15
 
@@ -70,7 +70,7 @@ module Neo4j::Embedded
70
70
  tx_methods :del
71
71
 
72
72
  def create_rel(type, other_node, props = nil)
73
- rel = create_relationship_to(other_node, ToJava.type_to_java(type))
73
+ rel = create_relationship_to(other_node.neo4j_obj, ToJava.type_to_java(type))
74
74
  props.each_pair { |k, v| rel[k] = v } if props
75
75
  rel
76
76
  end
@@ -87,7 +87,7 @@ module Neo4j::Embedded
87
87
 
88
88
  def node(match={})
89
89
  rel = _rel(match)
90
- rel && rel.other_node(self)
90
+ rel && rel.other_node(self).wrapper
91
91
  end
92
92
  tx_methods :node
93
93
 
@@ -148,8 +148,8 @@ module Neo4j::Embedded
148
148
  def class
149
149
  Neo4j::Node
150
150
  end
151
- #include Neo4j::Core::Label
152
- include Neo4j::Wrapper
151
+
152
+ include Neo4j::Node::Wrapper
153
153
  end
154
154
  end
155
155
  end
@@ -6,9 +6,10 @@ module Neo4j::Embedded
6
6
  java_clazz.class_eval do
7
7
  include Neo4j::Embedded::Property
8
8
  include Neo4j::EntityEquality
9
+ include Neo4j::Relationship::Wrapper
9
10
  extend Neo4j::Core::TxMethods
10
11
 
11
- alias_method :other_node, :getOtherNode
12
+ alias_method :_other_node, :getOtherNode
12
13
 
13
14
  def exist?
14
15
  !!graph_database.get_relationship_by_id(neo_id)
@@ -18,7 +19,7 @@ module Neo4j::Embedded
18
19
  tx_methods :exist?
19
20
 
20
21
  def start_node
21
- getStartNode
22
+ getStartNode.wrapper
22
23
  end
23
24
  tx_methods :start_node
24
25
 
@@ -27,8 +28,12 @@ module Neo4j::Embedded
27
28
  end
28
29
  tx_methods :del
29
30
 
31
+ def other_node(n)
32
+ _other_node(n.neo4j_obj).wrapper
33
+ end
34
+
30
35
  def end_node
31
- getEndNode
36
+ getEndNode.wrapper
32
37
  end
33
38
  tx_methods :end_node
34
39
 
@@ -132,7 +132,7 @@ module Neo4j::Server
132
132
  r.data.map do |rel|
133
133
  next if r.uncommited? ? rel['row'].first.nil? : rel.first.nil?
134
134
  id = r.uncommited? ? rel['row'].first : rel.first
135
- clazz.new(@session, id)
135
+ clazz.new(@session, id).wrapper
136
136
  end.compact
137
137
  end
138
138
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha.4
4
+ version: 3.0.0.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-28 00:00:00.000000000 Z
11
+ date: 2014-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty