From aff60d368a9ecba76c7bc878a9dceb00b0825d40 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 12 Feb 2015 08:57:28 -0800 Subject: [PATCH] Added Blacklight.default_index --- lib/blacklight.rb | 8 ++++++-- lib/railties/blacklight.rake | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/blacklight.rb b/lib/blacklight.rb index 078456e22c..b4f9ac3ce2 100644 --- a/lib/blacklight.rb +++ b/lib/blacklight.rb @@ -62,8 +62,12 @@ def self.add_routes(router, options = {}) end def self.solr - Deprecation.warn Blacklight, "Blacklight.solr is deprecated and will be removed in 6.0.0. Use Blacklight::SolrRepository#connection instead", caller - @solr ||= Blacklight::SolrRepository.new(Blacklight::Configuration.new).connection + Deprecation.warn Blacklight, "Blacklight.solr is deprecated and will be removed in 6.0.0. Use Blacklight.default_index.connection instead", caller + default_index.connection + end + + def self.default_index + @default_index ||= Blacklight::SolrRepository.new(Blacklight::Configuration.new) end def self.solr_config diff --git a/lib/railties/blacklight.rake b/lib/railties/blacklight.rake index a3236845e9..ae829503ab 100644 --- a/lib/railties/blacklight.rake +++ b/lib/railties/blacklight.rake @@ -14,7 +14,7 @@ namespace :blacklight do desc "Put sample data into solr" task :seed do docs = YAML::load(File.open(File.join(Blacklight.root, 'solr', 'sample_solr_documents.yml'))) - conn = Blacklight::SolrRepository.new(Blacklight::Configuration.new).connection + conn = Blacklight.default_index.connection conn.add docs conn.commit end @@ -26,7 +26,7 @@ namespace :blacklight do errors = 0 verbose = ENV.fetch('VERBOSE', false).present? - conn = Blacklight::SolrRepository.new(Blacklight::Configuration.new).connection + conn = Blacklight.default_index.connection puts "[#{conn.uri}]" print " - admin/ping: "