# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 50 def primary_key source.model.primary_key.to_sym end
class ThinkingSphinx::ActiveRecord::SQLSource::Template
Attributes
source[R]
Public Class Methods
new(source)
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 4 def initialize(source) @source = source end
Public Instance Methods
apply()
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 8 def apply add_field class_column, :sphinx_internal_class_name add_attribute primary_key, :sphinx_internal_id, nil add_attribute class_column, :sphinx_internal_class, :string, :facet => true add_attribute '0', :sphinx_deleted, :integer end
Private Instance Methods
add_attribute(column, name, type, options = {})
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 18 def add_attribute(column, name, type, options = {}) source.attributes << ThinkingSphinx::ActiveRecord::Attribute.new( source.model, ThinkingSphinx::ActiveRecord::Column.new(column), options.merge(:as => name, :type => type) ) end
add_field(column, name, options = {})
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 25 def add_field(column, name, options = {}) source.fields << ThinkingSphinx::ActiveRecord::Field.new( source.model, ThinkingSphinx::ActiveRecord::Column.new(column), options.merge(:as => name) ) end
class_column()
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 32 def class_column if inheriting? adapter = source.adapter quoted_column = "#{adapter.quoted_table_name}.#{adapter.quote(model.inheritance_column)}" source.adapter.convert_blank quoted_column, "'#{model.sti_name}'" else "'#{model.name}'" end end
inheriting?()
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 42 def inheriting? model.column_names.include?(model.inheritance_column) end
model()
click to toggle source
# File lib/thinking_sphinx/active_record/sql_source/template.rb, line 46 def model source.model end
primary_key()
click to toggle source