Sha256: 42875cb2f84cbaf57c022368cb2f4ef4d1184d276e5fc28d07502e5767fd2414

Contents?: true

Size: 1023 Bytes

Versions: 2

Compression:

Stored size: 1023 Bytes

Contents

module Neoon
  module Client
    module Request

      def cypher(query, parameters = {})
        options = { :query => query, :params => parameters }
        post('/cypher', options)
      end
      alias_method :q, :cypher

      def get(path, options={})
        make_request(:get, '/db/data' + path, options)
      end

      def post(path, options={})
        make_request(:post, '/db/data' + path, options)
      end

      def put(path, options={})
        make_request(:put, '/db/data' + path, options)
      end

      def delete(path, options={})
        make_request(:delete, '/db/data' + path, options)
      end

    private

      def make_request(method, path, options)
        response = connection.send(method) do |request|
          case method
          when :get, :delete
            request.url(path, options)
          when :post, :put
            request.path = path
            request.body = options unless options.empty?
          end
        end
        response.body
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neoon-0.0.5 lib/neoon/client/request.rb
neoon-0.0.4 lib/neoon/client/request.rb