Sha256: 71b02738292d90f4528d0b7438f0d0e70c03e283155cbe1c1cf0e68760fde893

Contents?: true

Size: 872 Bytes

Versions: 7

Compression:

Stored size: 872 Bytes

Contents

class ThinkingSphinx::RealTime::Index::Template
  attr_reader :index

  def initialize(index)
    @index = index
  end

  def apply
    add_field class_column, :sphinx_internal_class_name

    add_attribute :id,          :sphinx_internal_id,    :integer
    add_attribute class_column, :sphinx_internal_class, :string, :facet => true
    add_attribute 0,            :sphinx_deleted,        :integer
  end

  private

  def add_attribute(column, name, type, options = {})
    index.add_attribute ThinkingSphinx::RealTime::Attribute.new(
      ThinkingSphinx::ActiveRecord::Column.new(*column),
      options.merge(:as => name, :type => type)
    )
  end

  def add_field(column, name)
    index.add_field ThinkingSphinx::RealTime::Field.new(
      ThinkingSphinx::ActiveRecord::Column.new(*column), :as => name
    )
  end

  def class_column
    [:class, :name]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.2 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.0.6 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.0.5 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.0.4 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.0.3 lib/thinking_sphinx/real_time/index/template.rb