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

Commit

Permalink
toevoegen van PR karmi#964 dat nu als monkey patch in coosy aanwezig is
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrigart committed Sep 6, 2016
1 parent 6176bd5 commit f757800
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/tire/delete_by_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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 @@ -20,7 +19,7 @@ def initialize(indices=nil, options={}, &block)
def perform
@response = Configuration.client.delete url
if @response.failure?
STDERR.puts "[REQUEST FAILED] #{self.to_curl}\n"
STDERR.puts "[REQUEST FAILED] #{to_curl}\n"
raise DeleteByQueryRequestFailed, @response.to_s
end
@json = MultiJson.decode(@response.body)
Expand All @@ -29,6 +28,15 @@ 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 @@ -44,13 +52,6 @@ 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 f757800

Please sign in to comment.