Permalink
Browse files

use adapt_to to speed up indexing

  • Loading branch information...
jcoyne committed May 24, 2012
1 parent 34d7469 commit 77c22abed54619b61bd9a83c4399e3f79da8b6d2
Showing with 4 additions and 4 deletions.
  1. +1 −1 Gemfile.lock
  2. +1 −1 lib/solrizer/fedora/indexer.rb
  3. +2 −2 spec/units/fedora_solrizer_spec.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- solrizer-fedora (2.1.0)
+ solrizer-fedora (2.2.0)
active-fedora (~> 4.0)
GEM
@@ -152,7 +152,7 @@ def create_document( obj )
# Load the object as an instance of each of its other models and get the corresponding solr fields
# Include :model_only=>true in the options in order to avoid adding the metadata from ActiveFedora::Base every time.
model_klazz_array.each do |klazz|
- instance = klazz.find(obj.pid)
+ instance = obj.adapt_to(klazz)
solr_doc = instance.to_solr(solr_doc, :model_only=>true)
logger.debug " added solr fields from #{klazz.to_s}"
end
@@ -14,7 +14,7 @@
end
it "should work with Fedora::FedoraObject objects" do
mock_object = stub(:pid=>"my:pid", :label=>"my label")
- ActiveFedora::Base.expects(:load_instance).with( mock_object.pid ).returns(mock_object)
+ ActiveFedora::Base.expects(:find).with( mock_object.pid ).returns(mock_object)
@solrizer.indexer.expects(:index).with( mock_object )
@solrizer.solrize( mock_object )
end
@@ -24,7 +24,7 @@
mock_object.stubs(:label)
mock_object.stubs(:datastreams).returns({'descMetadata'=>"foo","location"=>"bar"})
- ActiveFedora::Base.expects(:load_instance).with( "_PID_" ).returns(mock_object)
+ ActiveFedora::Base.expects(:find).with( "_PID_" ).returns(mock_object)
@solrizer.indexer.expects(:index).with(mock_object)
@solrizer.solrize("_PID_")
end

0 comments on commit 77c22ab

Please sign in to comment.