lib/sunspot/session.rb in outoftime-sunspot-0.8.2 vs lib/sunspot/session.rb in outoftime-sunspot-0.8.3

- old
+ new

@@ -42,14 +42,22 @@ end # # See Sunspot.index # + #-- + # FIXME The fact that we have to break this out by class and index each + # class separately is artificial, imposed by the fact that indexers + # are initialized with a particular setup, and are responsible for + # sending add messages to Solr. It might be worth considering a + # singleton indexer (per session) and have the indexer itself find + # the appropriate setup to use for each object. + # def index(*objects) objects.flatten! @updates += objects.length - for object in objects - indexer_for(object).add(object) + objects.group_by { |object| object.class }.each_pair do |clazz, objs| + indexer_for(objs.first).add(objs) end end # # See Sunspot.index!