Sha256: 8492aad951fc51c0f0c076076102f40c6c70134ea3ee39c2642f71b91793c20f

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 Bytes

Contents

# frozen_string_literal: true

require 'rack'
require 'proxes/request'

module ProxES
  class Request
    class Search < Request
      attr_reader :index, :type

      def index=(idx)
        @index = idx
        self.path_info = '/' + [index, type, id, endpoint]
                         .map { |v| v.is_a?(Array) ? v.join(',') : v }
                         .select { |v| !v.nil? && v != '' }.join('/')
      end

      def endpoint
        '_search'
      end

      def parse
        @index ||= check_part(path_parts[0])
        @type  ||= check_part(path_parts[1])
        @id    ||= check_part(path_parts[2])
      end

      def id
        @id == [] ? nil : @id
      end

      def indices?
        true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxes-0.5.1 lib/proxes/request/search.rb
proxes-0.5.0 lib/proxes/request/search.rb
proxes-0.4.4 lib/proxes/request/search.rb