Class: ThinkingSphinx::ActiveRecord::Attribute::SphinxPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb

Constant Summary

SPHINX_TYPES =
{
  :integer   => :uint,
  :boolean   => :bool,
  :timestamp => :timestamp,
  :float     => :float,
  :string    => :string,
  :bigint    => :bigint,
  :ordinal   => :str2ordinal,
  :wordcount => :str2wordcount
}

Instance Method Summary (collapse)

Constructor Details

- (SphinxPresenter) initialize(attribute, source)

Returns a new instance of SphinxPresenter



13
14
15
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 13

def initialize(attribute, source)
  @attribute, @source = attribute, source
end

Instance Method Details

- (Object) collection_type



17
18
19
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 17

def collection_type
  @attribute.multi? ? :multi : sphinx_type
end

- (Object) declaration



21
22
23
24
25
26
27
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 21

def declaration
  if @attribute.multi?
    multi_declaration
  else
    @attribute.name
  end
end

- (Object) sphinx_type



29
30
31
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 29

def sphinx_type
  SPHINX_TYPES[@attribute.type]
end