activecypher 0.14.2 → 0.15.2

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.
data/lib/cyrel.rb CHANGED
@@ -93,55 +93,34 @@ module Cyrel
93
93
  # When called like: node(:a) > rel(:r) > node(:b)
94
94
  # The rel(:r) is evaluated first, then > is called
95
95
  # So we need to modify the last relationship that was just added
96
- if @elements.last.is_a?(Cyrel::Pattern::Relationship)
97
- # Replace the last relationship with one that has the correct direction
98
- last_rel = @elements.pop
99
- new_rel = Cyrel::Pattern::Relationship.new(
100
- alias_name: last_rel.alias_name,
101
- types: last_rel.types,
102
- properties: last_rel.properties,
103
- length: last_rel.length,
104
- direction: :outgoing
105
- )
106
- @elements << new_rel
107
- else
108
- @pending_direction = :outgoing
109
- end
110
- self
96
+ apply_direction(:outgoing)
111
97
  end
112
98
 
113
99
  def <(_other)
114
100
  # Same logic as > but for incoming direction
115
- if @elements.last.is_a?(Cyrel::Pattern::Relationship)
116
- last_rel = @elements.pop
117
- new_rel = Cyrel::Pattern::Relationship.new(
118
- alias_name: last_rel.alias_name,
119
- types: last_rel.types,
120
- properties: last_rel.properties,
121
- length: last_rel.length,
122
- direction: :incoming
123
- )
124
- @elements << new_rel
125
- else
126
- @pending_direction = :incoming
127
- end
128
- self
101
+ apply_direction(:incoming)
129
102
  end
130
103
 
131
104
  def -(_other)
132
105
  # Same logic as > but for bidirectional
106
+ apply_direction(:both)
107
+ end
108
+
109
+ private
110
+
111
+ def apply_direction(direction)
133
112
  if @elements.last.is_a?(Cyrel::Pattern::Relationship)
113
+ # Replace the last relationship with one that has the correct direction
134
114
  last_rel = @elements.pop
135
- new_rel = Cyrel::Pattern::Relationship.new(
115
+ @elements << Cyrel::Pattern::Relationship.new(
136
116
  alias_name: last_rel.alias_name,
137
117
  types: last_rel.types,
138
118
  properties: last_rel.properties,
139
119
  length: last_rel.length,
140
- direction: :both
120
+ direction: direction
141
121
  )
142
- @elements << new_rel
143
122
  else
144
- @pending_direction = :both
123
+ @pending_direction = direction
145
124
  end
146
125
  self
147
126
  end
@@ -256,9 +235,9 @@ module Cyrel
256
235
  # Example:
257
236
  # Cyrel.exists_block { match(Cyrel.node(:a) > Cyrel.rel(:r) > Cyrel.node(:b, :Admin)) }
258
237
  # # => EXISTS { MATCH (a)-[r]->(b:Admin) }
259
- def exists_block(&block)
238
+ def exists_block(&)
260
239
  subquery = Query.new
261
- subquery.instance_eval(&block)
240
+ subquery.instance_eval(&)
262
241
  Expression::ExistsBlock.new(subquery)
263
242
  end
264
243
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activecypher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  - !ruby/object:Gem::Version
294
294
  version: '0'
295
295
  requirements: []
296
- rubygems_version: 3.6.9
296
+ rubygems_version: 4.0.6
297
297
  specification_version: 4
298
298
  summary: OpenCypher Adapter ala ActiveRecord
299
299
  test_files: []