# File lib/thinking_sphinx/real_time/index/template.rb, line 45 def primary_key index.primary_key.to_sym end
class ThinkingSphinx::RealTime::Index::Template
Attributes
index[R]
Public Class Methods
new(index)
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 6 def initialize(index) @index = index end
Public Instance Methods
apply()
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 10 def apply add_field class_column, :sphinx_internal_class_name add_attribute primary_key, :sphinx_internal_id, :bigint add_attribute class_column, :sphinx_internal_class, :string, :facet => true add_attribute 0, :sphinx_deleted, :integer if tidying? add_attribute -> (_) { Time.current.to_i }, :sphinx_updated_at, :timestamp end end
Private Instance Methods
add_attribute(column, name, type, options = {})
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 24 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
add_field(column, name)
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 31 def add_field(column, name) index.add_field ThinkingSphinx::RealTime::Field.new( ThinkingSphinx::ActiveRecord::Column.new(*column), :as => name ) end
class_column()
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 37 def class_column [:class, :name] end
config()
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 41 def config ThinkingSphinx::Configuration.instance end
primary_key()
click to toggle source
tidying?()
click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 49 def tidying? config.settings["real_time_tidy"] end