Sha256: b9164d35d4960d2b8b2acaebb5f578424145cf7f412ef3f3f964779f4176ce14

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 Bytes

Contents

module ThinkingSphinx
  class AbstractAdapter
    def initialize(model)
      @model = model
    end
    
    def setup
      # Deliberately blank - subclasses should do something though. Well, if
      # they need to.
    end
      
    def self.detect(model)
      case model.connection.class.name
      when "ActiveRecord::ConnectionAdapters::MysqlAdapter",
           "ActiveRecord::ConnectionAdapters::MysqlplusAdapter"
        ThinkingSphinx::MysqlAdapter.new model
      when "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter"
        ThinkingSphinx::PostgreSQLAdapter.new model
      else
        raise "Invalid Database Adapter: Sphinx only supports MySQL and PostgreSQL, not #{model.connection.class.name}"
      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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
freelancing-god-thinking-sphinx-1.1.6 lib/thinking_sphinx/adapters/abstract_adapter.rb
lostboy-thinking-sphinx-1.1.5.1 lib/thinking_sphinx/adapters/abstract_adapter.rb
lostboy-thinking-sphinx-1.1.5.2 lib/thinking_sphinx/adapters/abstract_adapter.rb
lostboy-thinking-sphinx-1.1.5.3 lib/thinking_sphinx/adapters/abstract_adapter.rb
lostboy-thinking-sphinx-1.1.5.4 lib/thinking_sphinx/adapters/abstract_adapter.rb
lostboy-thinking-sphinx-1.1.5.5 lib/thinking_sphinx/adapters/abstract_adapter.rb