lib/georgia/indexer.rb in georgia-0.7.6 vs lib/georgia/indexer.rb in georgia-0.7.7

- old
+ new

@@ -1,6 +1,7 @@ require 'active_support/concern' +require 'georgia/indexer/adapter' module Georgia module Indexer autoload :SolrAdapter, 'georgia/indexer/solr_adapter' autoload :TireAdapter, 'georgia/indexer/tire_adapter' @@ -12,52 +13,21 @@ # Delegates search to the adapter def self.search model, params adapter.search model, params end + def self.register_extension indexer, klass + return unless indexer == Georgia.indexer + Adapter.load_extension(klass) + end + private def self.adapter_lookup @adapter_lookup ||= (case Georgia.indexer when :solr then SolrAdapter when :tire then TireAdapter - else - TireAdapter end) - end - - module Adapter - - class << self - def included(klass) - extension = Extension.new(klass) - begin - require extension.path - klass.send(:include, extension.name) - rescue => ex - raise "No extension for the #{Georgia.indexer} indexer: #{ex.message}" - end - end - - class Extension - def initialize klass - @klass = klass - end - - def name - name = @klass.to_s.gsub('::', '') + 'Extension' - "#{Georgia::Indexer.adapter}::#{name}".constantize - end - - def path - "georgia/indexer/extensions/#{Georgia.indexer}_adapter/#{filename}" - end - - def filename - @klass.to_s.underscore - end - end - end end end end \ No newline at end of file