doing away with brittle case statement

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@501328 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-01-30 06:54:50 +00:00
parent 05d7b69626
commit 54bf86c7b8
1 changed files with 5 additions and 14 deletions

View File

@ -28,20 +28,11 @@ class Solr::Response::Base
# TODO: Factor out this case... perhaps the request object should provide the response class instead? Or dynamically align by class name?
# Maybe the request itself could have the response handling features that get mixed in with a single general purpose response object?
case request
when Solr::Request::Ping
return Solr::Response::Ping.new(raw)
when Solr::Request::AddDocument
return Solr::Response::AddDocument.new(raw)
when Solr::Request::Commit
return Solr::Response::Commit.new(raw)
when Solr::Request::Standard
return Solr::Response::Standard.new(raw)
when Solr::Request::Delete
return Solr::Response::Delete.new(raw)
when Solr::Request::IndexInfo
return Solr::Response::IndexInfo.new(raw)
else
begin
klass = eval(request.class.name.sub(/Request/,'Response'))
klass.new(raw)
rescue
raise Solr::Exception.new("unknown request type: #{request.class}")
end
end