Sha256: 7424c5c3716fe75a8d928d20613b73955d43009bfd4f4c1a8d6d7674b77b8996

Contents?: true

Size: 871 Bytes

Versions: 7

Compression:

Stored size: 871 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,    :bigint
    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.4.2 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.1.4 lib/thinking_sphinx/real_time/index/template.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/real_time/index/template.rb