Sha256: b793ceabf822b89e4299ec497155e73fda491472226016eca96222155ff61311

Contents?: true

Size: 932 Bytes

Versions: 5

Compression:

Stored size: 932 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"
      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

5 entries across 5 versions & 4 rubygems

Version Path
dpickett-thinking-sphinx-1.1.4 lib/thinking_sphinx/adapters/abstract_adapter.rb
freelancing-god-thinking-sphinx-1.1.4 lib/thinking_sphinx/adapters/abstract_adapter.rb
freelancing-god-thinking-sphinx-1.1.5 lib/thinking_sphinx/adapters/abstract_adapter.rb
pixeltrix-thinking-sphinx-1.1.5 lib/thinking_sphinx/adapters/abstract_adapter.rb
sherpa99-thinking-sphinx-1.1.4 lib/thinking_sphinx/adapters/abstract_adapter.rb