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

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(attribute, source) ⇒ SphinxPresenter

Returns a new instance of SphinxPresenter.



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

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

Instance Method Details

#collection_typeObject



20
21
22
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 20

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

#declarationObject



24
25
26
27
28
29
30
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 24

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

#sphinx_typeObject



32
33
34
# File 'lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb', line 32

def sphinx_type
  SPHINX_TYPES[@attribute.type]
end