Skip to content

Commit

Permalink
Restore fallback to Blacklight::Solr::SearchBuilder, which will be re…
Browse files Browse the repository at this point in the history
…moved in Blacklight 6
  • Loading branch information
cbeer committed Nov 6, 2015
1 parent 7caea2b commit 7ceb87e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/blacklight/configuration.rb
Expand Up @@ -226,6 +226,14 @@ def search_builder_class

def locate_search_builder_class
::SearchBuilder
rescue NameError => e
# If the NameError is a result of the SearchBuilder having a
# NameError (e.g. NoMethodError) within it then raise the error.
raise e if Object.const_defined? "::SearchBuilder"

# Otherwise the NameError was a result of not being able to find SearchBuilder
Deprecation.warn(Configuration, "Your application is missing the SearchBuilder. Have you run `rails generate blacklight:search_builder`? Falling back to Blacklight::Solr::SearchBuilder")
Blacklight::Solr::SearchBuilder
end

def facet_paginator_class
Expand Down
1 change: 1 addition & 0 deletions lib/blacklight/solr.rb
Expand Up @@ -6,6 +6,7 @@ module Solr
autoload :Repository, 'blacklight/solr/repository'
autoload :Request, 'blacklight/solr/request'
autoload :Response, 'blacklight/solr/response'
autoload :SearchBuilder, 'blacklight/solr/search_builder'
autoload :SearchBuilderBehavior, 'blacklight/solr/search_builder_behavior'
end
end
7 changes: 7 additions & 0 deletions lib/blacklight/solr/search_builder.rb
@@ -0,0 +1,7 @@
module Blacklight::Solr
# @deprecated In 6.0 you should have this class generated into your application and Blacklight will
# no longer need to provide it.
class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
end
end

0 comments on commit 7ceb87e

Please sign in to comment.