Sha256: 34d4b911764ffff53da7c3f462fb3b5eb253b1c19582eaa6d3db31e9475efa4d

Contents?: true

Size: 809 Bytes

Versions: 25

Compression:

Stored size: 809 Bytes

Contents

module Elastics
  module HttpClients
    class RestClient < Base

      def request(method, path, data=nil)
        url  = "#{base_uri}#{path}"
        opts = options.merge( :method  => method.to_s.downcase.to_sym,
                              :url     => url,
                              :payload => data )
        response = ::RestClient::Request.new( opts ).execute
        extend_response(response, url)

      rescue ::RestClient::ExceptionWithResponse => e
        extend_response(e.response, url)
      end

    private

      def extend_response(response, url)
        response.extend ResponseExtension
        response.url = url
        response
      end

      module ResponseExtension
        attr_accessor :url

        def status
          code.to_i
        end

      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
elastics-client-1.3.3 lib/elastics/http_clients/rest_client.rb
elastics-client-1.3.2 lib/elastics/http_clients/rest_client.rb
elastics-client-1.3.1 lib/elastics/http_clients/rest_client.rb
elastics-client-1.3.0 lib/elastics/http_clients/rest_client.rb
elastics-client-1.2.1 lib/elastics/http_clients/rest_client.rb
elastics-client-1.2.0 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.11 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.10 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.9 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.8 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.7 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.6 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.5 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.4 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.3 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.2 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.1 lib/elastics/http_clients/rest_client.rb
elastics-client-1.1.0 lib/elastics/http_clients/rest_client.rb
elastics-client-1.0.10 lib/elastics/http_clients/rest_client.rb
elastics-client-1.0.9 lib/elastics/http_clients/rest_client.rb