Permalink
Browse files

Use RSolr::Client#request method directly

Fixes obscure method lookup issues that occur when calling the
:select method via a __send__ and received by a method_missing.
  • Loading branch information...
1 parent 1454bb7 commit 0e20b31dcf078a343e216fd11943146d670ef28d Mat Brown committed Mar 30, 2010
Showing with 10 additions and 7 deletions.
  1. +1 −1 sunspot/lib/sunspot/search/abstract_search.rb
  2. +9 −6 sunspot/spec/mocks/connection.rb
@@ -32,7 +32,7 @@ def initialize(connection, setup, query, configuration) #:nodoc:
def execute
reset
params = @query.to_params
- @solr_result = @connection.__send__(request_handler, params)
+ @solr_result = @connection.request("/#{request_handler}", params)
self
end
@@ -50,13 +50,16 @@ def commit
@commits << Time.now
end
- def method_missing(method, *args, &block)
- if method.to_sym == @expected_handler
- @searches << @last_search = args.first
- @response || {}
- else
- super
+ def request(path, params)
+ unless path == "/#{@expected_handler}"
+ raise ArgumentError, "Expected request to #{@expected_handler} request handler"
end
+ @searches << @last_search = params
+ @response || {}
+ end
+
+ def method_missing(method, *args, &block)
+ request("/#{method}", *args)
end
def has_add_with?(*documents)

0 comments on commit 0e20b31

Please sign in to comment.