neo4j 4.1.2 → 4.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b250e0735aaa127d7d195085c3a19701cc2f4b6f
4
- data.tar.gz: 6075c523fd160cb11aa0a4669d49c56c3a875561
3
+ metadata.gz: fc205134a4b67af95256deb3b4d72808e387e9a1
4
+ data.tar.gz: fb4afe4dac4036b227867b1dd771bb13b1a067df
5
5
  SHA512:
6
- metadata.gz: e6306ab117ee233f4470597bd97974930fc56892aff959b3c1c1241bc4fc86d1cc9d9ae2d4bca5bd9f25b22d85cb5debea624daf5ee408d28a81458ef8b1156b
7
- data.tar.gz: 2835569c30076f2a82ec0e7785077ff50abd9d0777de3d43aa981f6fc6796c923d7e61b4553162e1fbc787920f78fb8676306edaaf8c165720e7f31db1097bb5
6
+ metadata.gz: 3d9a385384d249676e13f41da6ab838ab7ba9c56808ccab74bbe1e02c44798d91c179477181b8b554d60eabf6cb69b74452527ff9bc5717c8c82dc50cdab204c
7
+ data.tar.gz: 7beacde3a246b22f70fe45f1bf08ba5ccd5de7a89d35aa56a40f71ae99b4f1af96d3a783fde036482133efc57c8cb511bb5f25d84d57809d94b4960b63000e80
@@ -106,6 +106,7 @@ module Neo4j::ActiveNode
106
106
  start_object: self,
107
107
  node: options[:node],
108
108
  rel: options[:rel],
109
+ optional: options[:optional],
109
110
  context: '#{self.name}##{name}',
110
111
  caller: self
111
112
  })
@@ -122,8 +123,8 @@ module Neo4j::ActiveNode
122
123
  end}, __FILE__, __LINE__)
123
124
 
124
125
  instance_eval(%{
125
- def #{name}(node = nil, rel = nil, proxy_obj = nil)
126
- #{name}_query_proxy(node: node, rel: rel, proxy_obj: proxy_obj)
126
+ def #{name}(node = nil, rel = nil, proxy_obj = nil, options = {})
127
+ #{name}_query_proxy({node: node, rel: rel, proxy_obj: proxy_obj}.merge(options))
127
128
  end
128
129
 
129
130
  def #{name}_query_proxy(options = {})
@@ -139,7 +140,7 @@ module Neo4j::ActiveNode
139
140
  node: options[:node],
140
141
  rel: options[:rel],
141
142
  context: context,
142
- optional: query_proxy.optional?,
143
+ optional: options[:optional] || query_proxy.optional?,
143
144
  caller: query_proxy.caller
144
145
  })
145
146
  end}, __FILE__, __LINE__)
@@ -180,9 +181,9 @@ module Neo4j::ActiveNode
180
181
  {session: self.neo4j_session}.merge(options))
181
182
  end
182
183
 
183
- def #{name}(node = nil, rel = nil, query_proxy = nil)
184
+ def #{name}(node = nil, rel = nil, query_proxy = nil, options = {})
184
185
  context = (query_proxy && query_proxy.context ? query_proxy.context : '#{self.name}') + '##{name}'
185
- #{name}_query_proxy(query_proxy: query_proxy, node: node, rel: rel, context: context)
186
+ #{name}_query_proxy({query_proxy: query_proxy, node: node, rel: rel, context: context}.merge(options))
186
187
  end}, __FILE__, __LINE__)
187
188
  end
188
189
  # rubocop:enable Style/PredicateName
@@ -41,6 +41,7 @@ module Neo4j
41
41
  @rel_var = options[:rel] || _rel_chain_var
42
42
  @session = options[:session]
43
43
  @caller = options[:caller]
44
+ @chain_level = options[:chain_level]
44
45
  @chain = []
45
46
  @starting_query = options[:starting_query]
46
47
  @optional = options[:optional]
@@ -87,9 +88,11 @@ module Neo4j
87
88
  starting_query ? (starting_query & _query_model_as(var)) : _query_model_as(var)
88
89
  end
89
90
  # Build a query chain via the chain, return the result
90
- @chain.inject(base_query.params(@params)) do |query, (method, arg)|
91
+ result_query = @chain.inject(base_query.params(@params)) do |query, (method, arg)|
91
92
  query.send(method, arg.respond_to?(:call) ? arg.call(var) : arg)
92
93
  end
94
+
95
+ result_query.tap { |query| query.proxy_chain_level = _chain_level }
93
96
  end
94
97
 
95
98
  # Scope all queries to the current scope.
@@ -246,6 +249,8 @@ module Neo4j
246
249
  def _chain_level
247
250
  if query_proxy = @options[:query_proxy]
248
251
  query_proxy._chain_level + 1
252
+ elsif @chain_level
253
+ @chain_level + 1
249
254
  else
250
255
  1
251
256
  end
@@ -114,11 +114,8 @@ module Neo4j
114
114
 
115
115
  # A shortcut for attaching a new, optional match to the end of a QueryProxy chain.
116
116
  # TODO: It's silly that we have to call constantize here. There should be a better way of finding the target class of the destination.
117
- def optional(association, node_id = nil)
118
- target_qp = self.send(association)
119
- model = target_qp.name.constantize
120
- var = node_id || target_qp.identity
121
- self.query.proxy_as(model, var, true)
117
+ def optional(association, node_var = nil, rel_var = nil)
118
+ self.send(association, node_var, rel_var, nil, optional: true)
122
119
  end
123
120
 
124
121
  private
@@ -8,12 +8,15 @@ module Neo4j::Core
8
8
  # @return [Neo4j::ActiveNode::Query::QueryProxy] A QueryProxy object.
9
9
  def proxy_as(model, var, optional = false)
10
10
  # TODO: Discuss whether it's necessary to call `break` on the query or if this should be left to the user.
11
- Neo4j::ActiveNode::Query::QueryProxy.new(model, nil, starting_query: self.break, node: var, optional: optional)
11
+ Neo4j::ActiveNode::Query::QueryProxy.new(model, nil, starting_query: self, node: var, optional: optional, chain_level: @proxy_chain_level)
12
12
  end
13
13
 
14
14
  # Calls proxy_as with `optional` set true. This doesn't offer anything different from calling `proxy_as` directly but it may be more readable.
15
15
  def proxy_as_optional(model, var)
16
16
  proxy_as(model, var, true)
17
17
  end
18
+ #
19
+ # For instances where you turn a QueryProxy into a Query and then back to a QueryProxy with `#proxy_as`
20
+ attr_accessor :proxy_chain_level
18
21
  end
19
22
  end
data/lib/neo4j/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = '4.1.2'
2
+ VERSION = '4.1.3'
3
3
  end
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: 4.1.2
4
+ version: 4.1.3
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-01-30 00:00:00.000000000 Z
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orm_adapter
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  requirements: []
295
295
  rubyforge_project: neo4j
296
- rubygems_version: 2.4.5
296
+ rubygems_version: 2.4.3
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: A graph database for Ruby