Class: Neography::Node

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

Instance Attribute Summary collapse

Attributes inherited from PropertyContainer

#neo_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Index

find, index

Methods included from Property

#[], #[]=, 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 inherited from PropertyContainer

#initialize

Constructor Details

This class inherits a constructor from Neography::PropertyContainer

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(*args) ⇒ Object



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

def create(*args)
  # the arguments can be an hash of properties to set or a rest instance
  props = (args[0].respond_to?(:each_pair) && args[0]) || args[1]
  db = (args[0].is_a?(Neography::Rest) && args[0]) || args[1] || Neography::Rest.new
  node = self.new(db.create_node(props))
  node.neo_server = db
  node
end

.load(*args) ⇒ Object



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

def load(*args)
  # the first argument can be an hash of properties to set
  node = !args[0].is_a?(Neography::Rest) && args[0] || args[1]

  # a db instance can be given, it is the first argument or the second
  db = (args[0].is_a?(Neography::Rest) && args[0]) || args[1] || Neography::Rest.new
  node = db.get_node(node)
  node = self.new(node) unless node.nil?
  node.neo_server = db unless node.nil?
  node
end

Instance Method Details

#delObject



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

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

#exist?Boolean

Returns:

  • (Boolean)


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

def exist?
  !self.neo_server.get_node(self.neo_id).nil?
end