Module: Neo4j::Core::ToJava

Overview

A Utility class for translating Ruby object to Neo4j Java types

Class Method Summary collapse

Class Method Details

.dir_from_java(dir) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/neo4j-core/to_java.rb', line 19

def dir_from_java(dir)
  case dir
    when Java::OrgNeo4jGraphdb::Direction::OUTGOING then
      :outgoing
    when Java::OrgNeo4jGraphdb::Direction::BOTH then
      :both
    when Java::OrgNeo4jGraphdb::Direction::INCOMING then
      :incoming
    else
      raise "unknown direction '#{dir} / #{dir.class}'"
  end
end

.dir_to_java(dir) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/neo4j-core/to_java.rb', line 34

def dir_to_java(dir)
  case dir
    when :outgoing then
      Java::OrgNeo4jGraphdb::Direction::OUTGOING
    when :both then
      Java::OrgNeo4jGraphdb::Direction::BOTH
    when :incoming then
      Java::OrgNeo4jGraphdb::Direction::INCOMING
    else
      raise "unknown direction '#{dir}', expects argument: outgoing, :incoming or :both"
  end
end

.type_to_java(type) ⇒ Object



6
7
8
# File 'lib/neo4j-core/to_java.rb', line 6

def type_to_java(type)
  Java::OrgNeo4jGraphdb::DynamicRelationshipType.withName(type.to_s)
end

.types_to_java(types) ⇒ Object



12
13
14
# File 'lib/neo4j-core/to_java.rb', line 12

def types_to_java(types)
  types.inject([]) { |result, type| result << type_to_java(type) }.to_java(Java::OrgNeo4jGraphdb::RelationshipType)
end