You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by eh...@apache.org on 2007/01/13 05:31:48 UTC

svn commit: r495837 - /incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb

Author: ehatcher
Date: Fri Jan 12 20:31:47 2007
New Revision: 495837

URL: http://svn.apache.org/viewvc?view=rev&rev=495837
Log:
refactor Document slightly, allowing << to take multiple fields in a Hash

Modified:
    incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb

Modified: incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb?view=diff&rev=495837&r1=495836&r2=495837
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb (original)
+++ incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb Fri Jan 12 20:31:47 2007
@@ -23,7 +23,7 @@
     #   doc = Solr::Document.new(:creator => 'Jorge Luis Borges')
     def initialize(hash={})
       @fields = []
-      hash.each_pair {|k,v| @fields << Solr::Field.new(k => v)}
+      self << hash
     end
 
     # Append a Solr::Field
@@ -33,12 +33,12 @@
     # If you are truly lazy you can simply pass in a hash:
     #
     #   doc << {:creator => 'Jorge Luis Borges'}
-    def <<(field)
-      case field
+    def <<(fields)
+      case fields
       when Hash
-        @fields << Solr::Field.new(field)
+        fields.each_pair {|k,v| @fields << Solr::Field.new(k => v)}
       when Solr::Field
-        @fields << field
+        @fields << fields
       else
         raise "must pass in Solr::Field or Hash"
       end