Sha256: e536de4398214a71fdbeafca52617df65131d1a03d065bc0caa61006c3f95501

Contents?: true

Size: 735 Bytes

Versions: 7

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true
require 'rack'
require 'proxes/request'

module ProxES
  class Request
    class Search < Request
      attr_reader :index, :type
      attr_reader :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

7 entries across 7 versions & 1 rubygems

Version Path
proxes-0.4.0 lib/proxes/request/search.rb
proxes-0.3.6 lib/proxes/request/search.rb
proxes-0.3.5 lib/proxes/request/search.rb
proxes-0.3.3 lib/proxes/request/search.rb
proxes-0.3.2 lib/proxes/request/search.rb
proxes-0.3.1 lib/proxes/request/search.rb
proxes-0.3.0 lib/proxes/request/search.rb