From 5cd57a4a572c5148947a5380e3d5923c5fba6bae Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Thu, 26 Apr 2007 02:09:50 +0000 Subject: [PATCH] Add option to stringify symbols when looking them up from an original object. An alternate approach could be to have two different classes, one for objects with symbol keys, and one for string keys git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@532569 13f79535-47bb-0310-9956-ffa450edef68 --- client/ruby/solr-ruby/lib/solr/importer/mapper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ruby/solr-ruby/lib/solr/importer/mapper.rb b/client/ruby/solr-ruby/lib/solr/importer/mapper.rb index 837d1a54c33..d0acae99f66 100755 --- a/client/ruby/solr-ruby/lib/solr/importer/mapper.rb +++ b/client/ruby/solr-ruby/lib/solr/importer/mapper.rb @@ -11,8 +11,9 @@ # limitations under the License. class Solr::Importer::Mapper - def initialize(mapping) + def initialize(mapping, options={}) @mapping = mapping + @options = options end def field_data(orig_data, field_name) @@ -26,7 +27,7 @@ class Solr::Importer::Mapper when Proc field_mapping.call(orig_data) when Symbol - field_data(orig_data, field_mapping) + field_data(orig_data, @options[:stringify_symbols] ? field_mapping.to_s : field_mapping) when Enumerable field_mapping.collect {|orig_field_name| mapped_field_value(orig_data, orig_field_name)}.flatten else