Sha256: 7ca0b4de6876004c56a6b27a85be2d8aee35add033e8787390a8b7390b6b1d1b

Contents?: true

Size: 913 Bytes

Versions: 3

Compression:

Stored size: 913 Bytes

Contents

module Neo4j
  module ToJava

    def type_to_java(type)
      org.neo4j.graphdb.DynamicRelationshipType.withName(type.to_s)
    end

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

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

    def ensure_valid_props(hash)
      hash ||= {}
      Hash[ hash.each_pair.map{|k,v| [k.to_s, v]} ]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neo4j-2.0.0.alpha.5-java lib/neo4j/to_java.rb
neo4j-2.0.0.alpha.4-java lib/neo4j/to_java.rb
neo4j-2.0.0.alpha.3-java lib/neo4j/to_java.rb