Sha256: 6cdd803f44717ccbef04f357fcc7c2078835135a2a7ab1cf0ff8ff29d3d5e1a8

Contents?: true

Size: 734 Bytes

Versions: 2

Compression:

Stored size: 734 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

    add_attribute :id, :sphinx_internal_id, :integer
    add_attribute 0,   :sphinx_deleted,     :integer
  end

  private

  def add_attribute(column, name, type)
    index.attributes << ThinkingSphinx::RealTime::Attribute.new(
      ThinkingSphinx::ActiveRecord::Column.new(*column),
      :as => name, :type => type
    )
  end

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

  def class_column
    [:class, :name]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.0.rc lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.0.0.pre lib/thinking_sphinx/real_time/index/template.rb