Sha256: 8f09e02e976323ba273ba1698dee13e44cf89c7ca8710a1c1fee2efc9414c69f

Contents?: true

Size: 753 Bytes

Versions: 4

Compression:

Stored size: 753 Bytes

Contents

class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter
  def initialize(model, column, adapter, associations)
    @model, @column, @adapter, @associations = model, column, adapter, associations
  end

  def aggregate?
    path.aggregate?
  rescue Joiner::AssociationNotFound
    false
  end

  def with_table
    return __name if string?
    return nil unless exists?

    "#{associations.alias_for(__stack)}.#{adapter.quote __name}"
  end

  private

  attr_reader :model, :column, :adapter, :associations

  delegate :__stack, :__name, :string?, :to => :column

  def exists?
    path.model.column_names.include?(column.__name.to_s)
  rescue Joiner::AssociationNotFound
    false
  end

  def path
    Joiner::Path.new model, column.__stack
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.3 lib/thinking_sphinx/active_record/column_sql_presenter.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/active_record/column_sql_presenter.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/active_record/column_sql_presenter.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/active_record/column_sql_presenter.rb