|
1 | 1 | # |
2 | 2 | # Author:: Adam Jacob (<adam@opscode.com>) |
3 | | -# Copyright:: Copyright (c) 2009 Opscode, Inc. |
| 3 | +# Author:: Nuo Yan (<nuo@opscode.com>) |
| 4 | +# Copyright:: Copyright (c) 2010 Opscode, Inc. |
4 | 5 | # License:: Apache License, Version 2.0 |
5 | 6 | # |
6 | 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -30,11 +31,22 @@ class Solr |
30 | 31 | class Query < Chef::Solr |
31 | 32 |
|
32 | 33 | # Create a new Query object - takes the solr_url and optional |
33 | | - # couchdb_database to inflate objects into. |
34 | | - def initialize(solr_url=Chef::Config[:solr_url], database=Chef::Config[:couchdb_database]) |
| 34 | + # Chef::CouchDB object to inflate objects into. |
| 35 | + def initialize(solr_url=Chef::Config[:solr_url], couchdb = nil) |
35 | 36 | super(solr_url) |
36 | | - @database = database |
37 | | - @couchdb = Chef::CouchDB.new(nil, database) |
| 37 | + if couchdb.nil? |
| 38 | + @database = Chef::Config[:couchdb_database] |
| 39 | + @couchdb = Chef::CouchDB.new(nil, Chef::Config[:couchdb_database]) |
| 40 | + else |
| 41 | + unless couchdb.kind_of?(Chef::CouchDB) |
| 42 | + Chef::Log.warn("Passing the database name to Chef::Solr::Query initialization is deprecated. Please pass in the Chef::CouchDB object instead.") |
| 43 | + @database = couchdb |
| 44 | + @couchdb = Chef::CouchDB.new(nil, couchdb) |
| 45 | + else |
| 46 | + @database = couchdb.couchdb_database |
| 47 | + @couchdb = couchdb |
| 48 | + end |
| 49 | + end |
38 | 50 | end |
39 | 51 |
|
40 | 52 | # A raw query against CouchDB - takes the type of object to find, and raw |
|
0 commit comments