Module: Neo4j::Wrapper::NodeMixin::Initialize

Included in:
NodeMixin
Defined in:
lib/neo4j-wrapper/node_mixin/initialize.rb

Instance Method Summary collapse

Instance Method Details

#_java_nodeNeo4j::Node Also known as: _java_entity

Returns the org.neo4j.graphdb.Node wrapped object

Returns:

  • (Neo4j::Node)

    Returns the org.neo4j.graphdb.Node wrapped object

See Also:



26
27
28
# File 'lib/neo4j-wrapper/node_mixin/initialize.rb', line 26

def _java_node
  @_java_node
end

#init_on_create(*args) ⇒ Object

Creates a new node and initialize with given properties. You can override this to provide your own initialization.

Parameters:

  • args (Object, :each_pair)

    if the first item in the list implements :each_pair then it will be initialize with those properties



17
18
19
20
21
22
# File 'lib/neo4j-wrapper/node_mixin/initialize.rb', line 17

def init_on_create(*args)
  _java_entity[:_classname] = self.class.to_s
  if args[0].respond_to?(:each_pair)
    args[0].each_pair { |k, v| respond_to?("#{k}=") ? self.send("#{k}=", v) : _java_entity[k] = v }
  end
end

#init_on_load(java_node) ⇒ Object

Init this node with the specified java neo node

Parameters:

  • java_node (Neo4j::Node)

    the node this instance wraps



8
9
10
# File 'lib/neo4j-wrapper/node_mixin/initialize.rb', line 8

def init_on_load(java_node)
  @_java_node = java_node
end

#wrapperObject

Implements the Neo4j::Node#wrapper and Neo4j::Relationship#wrapper method so that we don’t have to care if the node is wrapped or not.

Returns:

  • self



33
34
35
# File 'lib/neo4j-wrapper/node_mixin/initialize.rb', line 33

def wrapper
  self
end