Sha256: 3305ae65c2adf4d2c3f92525c4bd402619c4bde92afaddfa1611d7db8fb79646

Contents?: true

Size: 957 Bytes

Versions: 39

Compression:

Stored size: 957 Bytes

Contents

module Picky
  class Client
    
    # TODO Rename?
    #
    # 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::Post.new(self.path), index_name, data
    end
    
    # TODO Rename?
    #
    # 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

39 entries across 39 versions & 1 rubygems

Version Path
picky-client-4.12.4 lib/picky-client/client_index.rb
picky-client-4.12.3 lib/picky-client/client_index.rb
picky-client-4.12.2 lib/picky-client/client_index.rb
picky-client-4.12.1 lib/picky-client/client_index.rb
picky-client-4.12.0 lib/picky-client/client_index.rb
picky-client-4.11.3 lib/picky-client/client_index.rb
picky-client-4.11.2 lib/picky-client/client_index.rb
picky-client-4.11.1 lib/picky-client/client_index.rb
picky-client-4.11.0 lib/picky-client/client_index.rb
picky-client-4.10.0 lib/picky-client/client_index.rb
picky-client-4.9.0 lib/picky-client/client_index.rb
picky-client-4.8.1 lib/picky-client/client_index.rb
picky-client-4.8.0 lib/picky-client/client_index.rb
picky-client-4.7.0 lib/picky-client/client_index.rb
picky-client-4.6.6 lib/picky-client/client_index.rb
picky-client-4.6.5 lib/picky-client/client_index.rb
picky-client-4.6.4 lib/picky-client/client_index.rb
picky-client-4.6.3 lib/picky-client/client_index.rb
picky-client-4.6.2 lib/picky-client/client_index.rb
picky-client-4.6.1 lib/picky-client/client_index.rb