Class: Neo4j::Node

Overview

A node in the graph with properties and relationships to other entities. Along with relationships, nodes are the core building blocks of the Neo4j data representation model. Node has three major groups of operations: operations that deal with relationships, operations that deal with properties and operations that traverse the node space. The property operations give access to the key-value property pairs. Property keys are always strings. Valid property value types are the primitives (String, Fixnum, Float, Boolean), and arrays of those primitives.

The Neo4j::Node#new method does not return a new Ruby instance (!). Instead it will call the Neo4j Java API which will return a org.neo4j.kernel.impl.core.NodeProxy object. This java object includes the same mixin as this class. The #class method on the java object returns Neo4j::Node in order to make it feel like an ordinary Ruby object.

Examples:

Create a node with one property (see Core::Node::ClassMethods)

Neo4j::Node.new(:name => 'andreas')

Create a relationship (see Core::Traversal)

Neo4j::Node.new.outgoing(:friends) << Neo4j::Node.new

Finding relationships (see Core::Rels)

node.rels(:outgoing, :friends)

Lucene index (see Core::Index)

Neo4j::Node.trigger_on(:typex => 'MyTypeX')
Neo4j::Node.index(:name)
a = Neo4j::Node.new(:name => 'andreas', :typex => 'MyTypeX')
# finish_tx
Neo4j::Node.find(:name => 'andreas').first.should == a

Instance Attribute Summary

Attributes included from Core::Index::ClassMethods

#_indexer

Class Method Summary collapse

Methods included from Core::Node::ClassMethods

_load, exist?, load, new

Methods included from Core::Wrapper::ClassMethods

default_protected_keys, protected_keys, protected_keys=, wrapper, wrapper_proc=

Methods included from Core::Index::ClassMethods

_config, add_index, find, has_index_type?, index, index?, index_for_type, index_name_for_type, index_type, indexer, node_indexer, put_if_absent, rel_indexer, rm_index, rm_index_config, rm_index_type, trigger_on

Methods included from Core::Index

#add_index, #rm_index

Methods included from Core::Property::Java

#get_property, #graph_database, #property_keys, #remove_property, #set_property

Methods included from Core::Wrapper

#_java_entity, #wrapper

Methods included from Core::Node

#_java_node, #class, #del, #exist?

Methods included from Core::Equal

#==, #eql?, #equal?

Methods included from Core::Traversal

#both, #eval_paths, #expand, #incoming, #outgoing, #unique

Methods included from Core::ToJava

dir_from_java, dir_to_java, type_to_java, types_to_java

Methods included from Core::Rels

#_node, #_nodes, #_rel, #_rels, #node, #nodes, #rel, #rel?, #rels

Methods included from Core::Property

#[], #[]=, #neo_id, #property?, #props, #protected_keys, #update

Class Method Details

.extend_java_class(java_clazz) ⇒ Object

This method is used to extend a Java Neo4j class so that it includes the same mixins as this class.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/neo4j/node.rb', line 50

def extend_java_class(java_clazz)
  java_clazz.class_eval do
    include Neo4j::Core::Property
    include Neo4j::Core::Rels
    include Neo4j::Core::Traversal
    include Neo4j::Core::Equal
    include Neo4j::Core::Node
    include Neo4j::Core::Wrapper
    include Neo4j::Core::Index
  end
end