Class: Xapit::Client::RemoteDatabase

Inherits:
Object
  • Object
show all
Defined in:
lib/xapit/client/remote_database.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ RemoteDatabase

Returns a new instance of RemoteDatabase.



4
5
6
# File 'lib/xapit/client/remote_database.rb', line 4

def initialize(url)
  @url = url
end

Instance Method Details

#request(command, options) ⇒ Object



14
15
16
17
18
# File 'lib/xapit/client/remote_database.rb', line 14

def request(command, options)
  uri = URI.parse("#{@url}/xapit/#{command}")
  response = Net::HTTP.start(uri.host, uri.port) { |http| http.request_post(uri.path, options.to_json) }
  Xapit.symbolize_keys(JSON.parse("[#{response.body}]").first) # terrible hack for handling simple objects
end