Class: Neography::Node

Inherits:
PropertyContainer show all
Includes:
Equal, Index, NodePath, NodeRelationship, Property
Defined in:
lib/neography/node.rb

Constant Summary

Constants included from NodeRelationship

Neography::NodeRelationship::DIRECTIONS

Instance Attribute Summary collapse

Attributes inherited from PropertyContainer

#neo_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Property

#[], #[]=, #attributes, #method_missing, #new_ostruct_member

Methods included from Equal

#==, #eql?, #equal?

Methods included from NodePath

#all_paths_to, #all_shortest_paths_to, #all_simple_paths_to, #path_to, #shortest_path_to, #simple_path_to

Methods included from NodeRelationship

#both, #incoming, #outgoing, #rel, #rel?, #rels

Methods included from Index

#add_to_index, included, #remove_from_index

Methods inherited from PropertyContainer

#initialize

Constructor Details

This class inherits a constructor from Neography::PropertyContainer

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Neography::Property

Instance Attribute Details

#neo_serverObject

Returns the value of attribute neo_server.



9
10
11
# File 'lib/neography/node.rb', line 9

def neo_server
  @neo_server
end

Class Method Details

.create(props = nil, db = Neography::Rest.new) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'lib/neography/node.rb', line 12

def create(props = nil, db = Neography::Rest.new)
  raise ArgumentError.new("syntax deprecated") if props.is_a?(Neography::Rest)

  node = self.new(db.create_node(props))
  node.neo_server = db
  node
end

.load(node, db = Neography::Rest.new) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
29
# File 'lib/neography/node.rb', line 20

def load(node, db = Neography::Rest.new)
  raise ArgumentError.new("syntax deprecated") if node.is_a?(Neography::Rest)
  node = node.first if node.kind_of?(Array)
  node = db.get_node(node) if (node.to_s.match(/^\d+$/) or node.to_s.split("/").last.match(/^\d+$/))
  if node
    node = self.new(node)
    node.neo_server = db
  end
  node
end

Instance Method Details

#delObject



39
40
41
# File 'lib/neography/node.rb', line 39

def del
  neo_server.delete_node!(self.neo_id)
end

#exist?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
# File 'lib/neography/node.rb', line 43

def exist?
  begin
    neo_server.get_node(self.neo_id)
    true
  rescue NodeNotFoundException
    false
  end
end

#find(*args) ⇒ Object



34
35
36
37
# File 'lib/neography/node.rb', line 34

def find(*args)
  node = self.new
  node.find(args)
end