lib/xapian_db/config.rb in xapian_db-1.2.2.2 vs lib/xapian_db/config.rb in xapian_db-1.2.3

- old
+ new

@@ -83,11 +83,15 @@ # @param [Symbol] type The adapter type; the following adapters are available: # - :generic ({XapianDb::Adapters::GenericAdapter}) # - :active_record ({XapianDb::Adapters::ActiveRecordAdapter}) # - :datamapper ({XapianDb::Adapters::DatamapperAdapter}) def adapter(type) - # We try to guess the adapter name - @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") + begin + @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") + rescue NameError + require File.dirname(__FILE__) + "/adapters/#{type}_adapter" + @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") + end end # Set the index writer # @param [Symbol] type The writer type; the following adapters are available: # - :direct ({XapianDb::IndexWriters::DirectWriter})