lib/thinking_sphinx/adapters/abstract_adapter.rb in freelancing-god-thinking-sphinx-1.1.2 vs lib/thinking_sphinx/adapters/abstract_adapter.rb in freelancing-god-thinking-sphinx-1.1.3
- old
+ new
@@ -1,27 +1,33 @@
module ThinkingSphinx
class AbstractAdapter
- class << self
- def setup
- # Deliberately blank - subclasses should do something though. Well, if
- # they need to.
- end
+ def initialize(model)
+ @model = model
+ end
+
+ def setup
+ # Deliberately blank - subclasses should do something though. Well, if
+ # they need to.
+ end
- def detect(model)
- case model.connection.class.name
- when "ActiveRecord::ConnectionAdapters::MysqlAdapter"
- ThinkingSphinx::MysqlAdapter
- when "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter"
- ThinkingSphinx::PostgreSQLAdapter
- else
- raise "Invalid Database Adapter: Sphinx only supports MySQL and PostgreSQL"
- end
+ def self.detect(model)
+ case model.connection.class.name
+ when "ActiveRecord::ConnectionAdapters::MysqlAdapter"
+ ThinkingSphinx::MysqlAdapter.new model
+ when "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter"
+ ThinkingSphinx::PostgreSQLAdapter.new model
+ else
+ raise "Invalid Database Adapter: Sphinx only supports MySQL and PostgreSQL"
end
-
- protected
-
- def connection
- @connection ||= ::ActiveRecord::Base.connection
- end
+ end
+
+ def quote_with_table(column)
+ "#{@model.quoted_table_name}.#{@model.connection.quote_column_name(column)}"
+ end
+
+ protected
+
+ def connection
+ @connection ||= @model.connection
end
end
end
\ No newline at end of file