Sha256: 36bb9e49d23a7d394685cf5bdc7aa4f0cb7100611e266963fdaf1ccad237bd1b

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

module Neo4j::Core
  module CypherTranslator
    # Cypher Helper
    def escape_value(value)
      case value
        when String
          "'#{value.gsub("'", %q(\\\'))}'"
        else
          value
      end
    end

    # Cypher Helper
    def cypher_prop_list(props)
      return "" unless props
      list = props.keys.map{|k| "#{k} : #{escape_value(props[k])}"}.join(',')
      "{#{list}}"
    end

    # Stolen from keymaker
    # https://github.com/therubymug/keymaker/blob/master/lib/keymaker/parsers/cypher_response_parser.rb
    def self.translate_response(response_body, result)
      Hashie::Mash.new(Hash[sanitized_column_names(response_body).zip(result)])
    end

    def self.sanitized_column_names(response_body)
      response_body.columns.map do |column|
        column[/[^\.]+$/]
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neo4j-core-3.0.0.alpha.9 lib/neo4j-core/cypher_translator.rb
neo4j-core-3.0.0.alpha.8 lib/neo4j-core/cypher_translator.rb
neo4j-core-3.0.0.alpha.7 lib/neo4j-core/cypher_translator.rb