Sha256: c1931eca380a89cff3620ff02af6231ee4f2ff243805af1948d2f2d058a0c9fb
Contents?: true
Size: 1.03 KB
Versions: 49
Compression:
Stored size: 1.03 KB
Contents
require 'active_support' module Picky class Client # Replaces an item in the index (adds it if not indexed yet). # # Parameters: # * index_name: An index that exists in the Picky server. # * data: A hash in the form of { :id => 1234, :attr1 => 'attr1', :attr2 => 'attr2', ... }. # def replace index_name, data send_off Net::HTTP::Put.new(self.path), index_name, data end # Removes an item from the index. # # Parameters: # * index_name: An index that exists in the Picky server. # * data: A hash in the form of { :id => 1234 }. # def remove index_name, data send_off Net::HTTP::Delete.new(self.path), index_name, data end # Sends a request to the Picky server. # # Note: Data is JSON encoded. # def send_off request, index_name, data = {} request.form_data = { :index => index_name, :data => ActiveSupport::JSON.encode(data) } Net::HTTP.new(self.host, self.port).start { |http| http.request request } end end end
Version data entries
49 entries across 49 versions & 1 rubygems