Module: Neo4j::Embedded::ToJava

Defined in:
lib/neo4j-embedded/to_java.rb

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
# File 'lib/neo4j-embedded/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
    fail "unknown direction '#{dir} / #{dir.class}'"
  end
end

.dir_to_java(dir) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/neo4j-embedded/to_java.rb', line 31

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
    fail "unknown direction '#{dir}', expects argument: outgoing, :incoming or :both"
  end
end

.type_to_java(type) ⇒ Object



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

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

.types_to_java(types) ⇒ Object



12
13
14
# File 'lib/neo4j-embedded/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