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)


370
371
372
# File 'lib/neo4j-cypher/context.rb', line 370

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)


377
378
379
# File 'lib/neo4j-cypher/context.rb', line 377

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)


391
392
393
# File 'lib/neo4j-cypher/context.rb', line 391

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)


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

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

#==(other) ⇒ Object



322
323
324
# File 'lib/neo4j-cypher/context.rb', line 322

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)


363
364
365
# File 'lib/neo4j-cypher/context.rb', line 363

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)


384
385
386
# File 'lib/neo4j-cypher/context.rb', line 384

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

#_get_or_create_node(rel_types) ⇒ Object



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

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



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

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)


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

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



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

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

#create_unique_path(*args, &cypher_dsl) ⇒ Object



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

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

#incoming(*rel_types) ⇒ Object



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

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)


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

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



327
328
329
330
# File 'lib/neo4j-cypher/context.rb', line 327

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

#outgoing(*rel_types) ⇒ Object



395
396
397
398
399
# File 'lib/neo4j-cypher/context.rb', line 395

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)


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

#with(*args, &cypher_dsl) ⇒ Object



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

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

#with_match(*args, &cypher_dsl) ⇒ Object



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

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