class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter

Attributes

adapter[R]
associations[R]
column[R]
model[R]

Public Class Methods

new(model, column, adapter, associations) click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 4
def initialize(model, column, adapter, associations)
  @model, @column, @adapter, @associations = model, column, adapter, associations
end

Public Instance Methods

aggregate?() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 8
def aggregate?
  path.aggregate?
rescue Joiner::AssociationNotFound
  false
end
with_table() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 14
def with_table
  return __name if string?
  return nil unless exists?

  quoted_table = escape_table? ? escape_table(table) : table

  "#{quoted_table}.#{adapter.quote __name}"
end

Private Instance Methods

escape_table(table_name) click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 29
def escape_table(table_name)
  table_name.split('.').map { |t| adapter.quote(t) }.join('.')
end
escape_table?() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 33
def escape_table?
  table[/[`"]/].nil?
end
exists?() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 37
def exists?
  path.model.column_names.include?(column.__name.to_s)
rescue Joiner::AssociationNotFound
  false
end
path() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 43
def path
  Joiner::Path.new model, column.__stack
end
table() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 47
def table
  associations.alias_for __stack
end
version() click to toggle source
# File lib/thinking_sphinx/active_record/column_sql_presenter.rb, line 51
def version
  ActiveRecord::VERSION
end