class ThinkingSphinx::ActiveRecord::Attribute::SphinxPresenter

Constants

SPHINX_TYPES

Public Class Methods

new(attribute, source) click to toggle source
# File lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb, line 14
def initialize(attribute, source)
  @attribute, @source = attribute, source
end

Public Instance Methods

collection_type() click to toggle source
# File lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb, line 18
def collection_type
  @attribute.multi? ? :multi : sphinx_type
end
declaration() click to toggle source
# File lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb, line 22
def declaration
  if @attribute.multi?
    multi_declaration
  else
    @attribute.name
  end
end
sphinx_type() click to toggle source
# File lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb, line 30
def sphinx_type
  SPHINX_TYPES[@attribute.type]
end

Private Instance Methods

multi_declaration() click to toggle source
# File lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb, line 36
def multi_declaration
  case @attribute.source_type
  when :query, :ranged_query
    query
  else
    "#{sphinx_type} #{@attribute.name} from field"
  end
end
query() click to toggle source
# File lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb, line 45
def query
  ThinkingSphinx::ActiveRecord::PropertyQuery.new(
    @attribute, @source, sphinx_type
  ).to_s
end