Class: Neo4j::Core::Cypher::Return

Inherits:
Expression show all
Defined in:
lib/neo4j-core/cypher/cypher.rb

Overview

The return statement in the cypher query

Instance Attribute Summary collapse

Attributes inherited from Expression

#clause, #expressions, #separator

Instance Method Summary collapse

Methods inherited from Expression

#insert_last, #prefix, #prefixes, #prev_clause, #valid?

Constructor Details

#initialize(name_or_ref, expressions, opts = {}) ⇒ Return

Returns a new instance of Return.



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

def initialize(name_or_ref, expressions, opts = {})
  super(expressions, :return)
  @name_or_ref = name_or_ref
  @name_or_ref.referenced! if @name_or_ref.respond_to?(:referenced!)
  @var_name = @name_or_ref.respond_to?(:var_name) ? @name_or_ref.var_name : @name_or_ref.to_s
  opts.each_pair { |k, v| self.send(k, v) }
end

Instance Attribute Details

#var_nameObject (readonly)

Returns the value of attribute var_name.



435
436
437
# File 'lib/neo4j-core/cypher/cypher.rb', line 435

def var_name
  @var_name
end

Instance Method Details

#as_return_methodObject



451
452
453
454
455
456
457
# File 'lib/neo4j-core/cypher/cypher.rb', line 451

def as_return_method
  if return_method[:bracket]
    "#{return_method[:name]}(#@var_name)"
  else
    "#{return_method[:name]} #@var_name"
  end
end

#asc(*props) ⇒ Object

Specifies an ORDER BY cypher query

Parameters:

  • props (Property)

    the properties which should be sorted

Returns:

  • self



462
463
464
465
466
467
# File 'lib/neo4j-core/cypher/cypher.rb', line 462

def asc(*props)
  @order_by ||= OrderBy.new(expressions)
  expressions.delete(props.first)
  @order_by.asc(props)
  self
end

#desc(*props) ⇒ Object

Specifies an ORDER BY cypher query

Parameters:

  • props (Property)

    the properties which should be sorted

Returns:

  • self



472
473
474
475
476
477
# File 'lib/neo4j-core/cypher/cypher.rb', line 472

def desc(*props)
  @order_by ||= OrderBy.new(expressions)
  expressions.delete(props.first)
  @order_by.desc(props)
  self
end

#limit(val) ⇒ Object

Creates a LIMIT cypher clause

Parameters:

  • val (Fixnum)

    the number of entries to limit

Returns:

  • self



490
491
492
493
# File 'lib/neo4j-core/cypher/cypher.rb', line 490

def limit(val)
  Limit.new(expressions, val)
  self
end

#return_methodObject



446
447
448
# File 'lib/neo4j-core/cypher/cypher.rb', line 446

def return_method
  @name_or_ref.respond_to?(:return_method) && @name_or_ref.return_method
end

#skip(val) ⇒ Object

Creates a SKIP cypher clause

Parameters:

  • val (Fixnum)

    the number of entries to skip

Returns:

  • self



482
483
484
485
# File 'lib/neo4j-core/cypher/cypher.rb', line 482

def skip(val)
  Skip.new(expressions, val)
  self
end

#to_sObject



495
496
497
# File 'lib/neo4j-core/cypher/cypher.rb', line 495

def to_s
  return_method ? as_return_method : var_name.to_s
end