lib/georgia/indexer.rb in georgia-0.7.3 vs lib/georgia/indexer.rb in georgia-0.7.4

- old
+ new

@@ -1,26 +1,44 @@ -require 'georgia/indexer/adapter' +require 'active_support/concern' module Georgia module Indexer autoload :SolrAdapter, 'georgia/indexer/solr_adapter' autoload :TireAdapter, 'georgia/indexer/tire_adapter' - mattr_accessor :adapter - - def self.included(base) + def self.adapter @@adapter ||= adapter_lookup end + # Delegates search to the adapter + def self.search model, params + adapter.search model, params + end + + def self.searching model, extension + adapter.searching model, extension + end + private def self.adapter_lookup (case Georgia.indexer - when :solr then Georgia::Indexer::SolrAdapter.new - when :tire then Georgia::Indexer::TireAdapter.new + when :solr then SolrAdapter.new + when :tire then TireAdapter.new else - Georgia::Indexer::TireAdapter.new + TireAdapter.new end) + end + + module Adapter + extend ActiveSupport::Concern + + included do + def self.is_searchable extensions={} + raise "No extension for the #{Georgia.indexer} indexer" unless extensions[Georgia.indexer].present? + self.send(:include, extensions[Georgia.indexer]) + end + end end end end \ No newline at end of file