Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Revert "toevoegen van PR karmi#964 dat nu als monkey patch in coosy a…
Browse files Browse the repository at this point in the history
…anwezig is"

This reverts commit f757800.
  • Loading branch information
michaelrigart committed Sep 6, 2016
1 parent f757800 commit 6db9e44
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/tire/delete_by_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def initialize(indices=nil, options={}, &block)

if block_given?
@query = Search::Query.new
block.arity < 1 ? @query.instance_eval(&block) : block.call(@query)
else
raise "no query given for #{self.class}"
end
Expand All @@ -19,7 +20,7 @@ def initialize(indices=nil, options={}, &block)
def perform
@response = Configuration.client.delete url
if @response.failure?
STDERR.puts "[REQUEST FAILED] #{to_curl}\n"
STDERR.puts "[REQUEST FAILED] #{self.to_curl}\n"
raise DeleteByQueryRequestFailed, @response.to_s
end
@json = MultiJson.decode(@response.body)
Expand All @@ -28,15 +29,6 @@ def perform
logged
end

def to_json(options={})
{query: query}.to_json
end

#Can be handy while debugging
def to_curl
%Q|curl -X DELETE '#{url}'|
end

private

def path
Expand All @@ -52,6 +44,13 @@ def url
"#{Configuration.url}#{path}/?source=#{Utils.escape(to_json)}"
end

def to_json(options={})
query.to_json
end

def to_curl
%Q|curl -X DELETE '#{url}'|
end

def logged(endpoint='_query')
if Configuration.logger
Expand Down

0 comments on commit 6db9e44

Please sign in to comment.