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
- .dir_from_java(dir) ⇒ Object
- .dir_to_java(dir) ⇒ Object
- .type_to_java(type) ⇒ Object
- .types_to_java(types) ⇒ Object
Class Method Details
.dir_from_java(dir) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/neo4j-embedded/to_java.rb', line 18 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
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/neo4j-embedded/to_java.rb', line 33 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
5 6 7 |
# File 'lib/neo4j-embedded/to_java.rb', line 5 def type_to_java(type) Java::OrgNeo4jGraphdb::DynamicRelationshipType.withName(type.to_s) end |
.types_to_java(types) ⇒ Object
11 12 13 |
# File 'lib/neo4j-embedded/to_java.rb', line 11 def types_to_java(types) types.inject([]) { |result, type| result << type_to_java(type) }.to_java(Java::OrgNeo4jGraphdb::RelationshipType) end |