Skip to content

Commit

Permalink
Do away with Blacklight::SearchBuilder
Browse files Browse the repository at this point in the history
Using an included module instead of class inheritance.
This should make generating a custom SearchBuilder simpler as it doesn't
need to inherit from a implementation tightly coupled to Solr (or
something else).
  • Loading branch information
jcoyne committed Mar 3, 2015
1 parent 0605807 commit 01d5897
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/blacklight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Blacklight
autoload :Configurable, 'blacklight/configurable'
autoload :Configuration, 'blacklight/configuration'
autoload :SearchFields, 'blacklight/search_fields'
autoload :SearchBuilder, 'blacklight/search_builder'
autoload :SearchBuilderBehavior, 'blacklight/search_builder_behavior'

autoload :Document, 'blacklight/document'
Expand Down
5 changes: 0 additions & 5 deletions lib/blacklight/search_builder.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/blacklight/solr/search_builder.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Blacklight::Solr
class SearchBuilder < Blacklight::SearchBuilder
class SearchBuilder
include SearchBuilderBehavior
end
end
1 change: 1 addition & 0 deletions lib/blacklight/solr/search_builder_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Blacklight::Solr
module SearchBuilderBehavior
include Blacklight::SearchBuilderBehavior
####
# Start with general defaults from BL config. Need to use custom
# merge to dup values, to avoid later mutating the original by mistake.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
require 'spec_helper'

describe Blacklight::SearchBuilder do
describe Blacklight::SearchBuilderBehavior do
let(:processor_chain) { [] }
let(:blacklight_config) { Blacklight::Configuration.new }
let(:scope) { double blacklight_config: blacklight_config }
subject { described_class.new processor_chain, scope }

before do
class TestBuilder
include Blacklight::SearchBuilderBehavior
end
end

after { Object.send(:remove_const, :TestBuilder) }

subject { TestBuilder.new processor_chain, scope }

describe "#with" do
it "should set the blacklight params" do
params = {}
Expand Down

0 comments on commit 01d5897

Please sign in to comment.