Module: Neo4j::Cypher::Context::Matchable

Defined in:
lib/neo4j-cypher/context.rb

Instance Method Summary collapse

Instance Method Details

#-(other) ⇒ MatchRelLeft, MatchNode

This operator means any direction related to

Parameters:

  • other (Symbol, #var_name, String)

    the relationship

Returns:

  • (MatchRelLeft, MatchNode)


380
381
382
# File 'lib/neo4j-cypher/context.rb', line 380

def -(other)
  MatchStart.new(clause).new_match_rel(other).eval_context
end

#<(other) ⇒ MatchRelLeft, MatchNode

This operator means incoming related to

Parameters:

  • other (Symbol, #var_name, String)

    the relationship

Returns:

  • (MatchRelLeft, MatchNode)


387
388
389
# File 'lib/neo4j-cypher/context.rb', line 387

def <(other)
  MatchStart.new(clause).new_match_rel(other).eval_context
end

#<<(other) ⇒ MatchRelLeft, MatchNode

Incoming relationship to other node

Parameters:

  • other (Symbol, #var_name)

    either a node (Symbol, #var_name)

Returns:

  • (MatchRelLeft, MatchNode)


401
402
403
# File 'lib/neo4j-cypher/context.rb', line 401

def <<(other)
  MatchStart.new_match_node(clause, other, :incoming).eval_context
end

#<=>(other) ⇒ MatchRelLeft, MatchNode

This operator means related to, without regard to type or direction.

Parameters:

  • other (Symbol, #var_name)

    either a node (Symbol, #var_name)

Returns:

  • (MatchRelLeft, MatchNode)


366
367
368
# File 'lib/neo4j-cypher/context.rb', line 366

def <=>(other)
  MatchStart.new_match_node(clause, other, :both).eval_context
end

#==(other) ⇒ Object



332
333
334
# File 'lib/neo4j-cypher/context.rb', line 332

def ==(other)
  Operator.new(clause_list, clause, other, "=").eval_context
end

#>(other) ⇒ MatchRelLeft, MatchNode

This operator means outgoing related to

Parameters:

  • other (Symbol, #var_name, String)

    the relationship

Returns:

  • (MatchRelLeft, MatchNode)


373
374
375
# File 'lib/neo4j-cypher/context.rb', line 373

def >(other)
  MatchStart.new(clause).new_match_rel(other).eval_context
end

#>>(other) ⇒ MatchRelLeft, MatchNode

Outgoing relationship to other node

Parameters:

  • other (Symbol, #var_name)

    either a node (Symbol, #var_name)

Returns:

  • (MatchRelLeft, MatchNode)


394
395
396
# File 'lib/neo4j-cypher/context.rb', line 394

def >>(other)
  MatchStart.new_match_node(clause, other, :outgoing).eval_context
end

#_get_or_create_node(rel_types) ⇒ Object



411
412
413
# File 'lib/neo4j-cypher/context.rb', line 411

def _get_or_create_node(rel_types)
  rel_types.last.kind_of?(Matchable) ? rel_types.pop.clause : NodeVar.new(clause.clause_list)
end

#both(*rel_types) ⇒ Object



433
434
435
436
437
# File 'lib/neo4j-cypher/context.rb', line 433

def both(*rel_types)
  node = _get_or_create_node(rel_types)
  MatchStart.new(clause).new_match_rels(rel_types).eval_context - node
  node.eval_context
end

#both?(*rel_types) ⇒ Boolean

Returns:

  • (Boolean)


439
440
441
442
443
# File 'lib/neo4j-cypher/context.rb', line 439

def both?(*rel_types)
  node = _get_or_create_node(rel_types)
  MatchStart.new(clause).new_match_rels?(rel_types).eval_context - node
  node.eval_context
end

#create_path(*args, &cypher_dsl) ⇒ Object



352
353
354
355
# File 'lib/neo4j-cypher/context.rb', line 352

def create_path(*args, &cypher_dsl)
  CreatePath.new(clause_list, self, *args, &cypher_dsl)
  self
end

#create_unique_path(*args, &cypher_dsl) ⇒ Object



357
358
359
360
# File 'lib/neo4j-cypher/context.rb', line 357

def create_unique_path(*args, &cypher_dsl)
  CreatePath.new(clause_list, self, *args, &cypher_dsl).unique!
  self
end

#incoming(*rel_types) ⇒ Object



421
422
423
424
425
# File 'lib/neo4j-cypher/context.rb', line 421

def incoming(*rel_types)
  node = _get_or_create_node(rel_types)
  MatchStart.new(clause).new_match_rels(rel_types).eval_context < node
  node.eval_context
end

#incoming?(*rel_types) ⇒ Boolean

Returns:

  • (Boolean)


427
428
429
430
431
# File 'lib/neo4j-cypher/context.rb', line 427

def incoming?(*rel_types)
  node = _get_or_create_node(rel_types)
  MatchStart.new(clause).new_match_rels?(rel_types).eval_context < node
  node.eval_context
end

#match(&cypher_dsl) ⇒ Object



337
338
339
340
# File 'lib/neo4j-cypher/context.rb', line 337

def match(&cypher_dsl)
  RootClause::EvalContext.new(self).instance_exec(self, &cypher_dsl)
  self
end

#outgoing(*rel_types) ⇒ Object



405
406
407
408
409
# File 'lib/neo4j-cypher/context.rb', line 405

def outgoing(*rel_types)
  node = _get_or_create_node(rel_types)
  MatchStart.new(clause).new_match_rels(rel_types).eval_context > node
  node.eval_context
end

#outgoing?(*rel_types) ⇒ Boolean

Returns:

  • (Boolean)


415
416
417
418
419
# File 'lib/neo4j-cypher/context.rb', line 415

def outgoing?(*rel_types)
  node = _get_or_create_node(rel_types)
  MatchStart.new(clause).new_match_rels?(rel_types).eval_context > node
  node.eval_context
end

#with(*args, &cypher_dsl) ⇒ Object



342
343
344
345
# File 'lib/neo4j-cypher/context.rb', line 342

def with(*args, &cypher_dsl)
  With.new(clause_list, :where, self, *args, &cypher_dsl)
  self
end

#with_match(*args, &cypher_dsl) ⇒ Object



347
348
349
350
# File 'lib/neo4j-cypher/context.rb', line 347

def with_match(*args, &cypher_dsl)
  With.new(clause_list, :match, self, *args, &cypher_dsl)
  self
end