# File lib/thinking_sphinx/real_time/index.rb, line 6 def initialize(reference, options = {}) @fields = [] @attributes = [] @conditions = [] Template.new(self).apply super reference, options end
# File lib/thinking_sphinx/real_time/index.rb, line 16 def add_attribute(attribute) @attributes << attribute end
# File lib/thinking_sphinx/real_time/index.rb, line 20 def add_field(field) @fields << field end
# File lib/thinking_sphinx/real_time/index.rb, line 24 def attributes interpret_definition! @attributes end
# File lib/thinking_sphinx/real_time/index.rb, line 30 def conditions interpret_definition! @conditions end
# File lib/thinking_sphinx/real_time/index.rb, line 36 def facets properties.select(&:facet?) end
# File lib/thinking_sphinx/real_time/index.rb, line 40 def fields interpret_definition! @fields end
# File lib/thinking_sphinx/real_time/index.rb, line 46 def scope @scope.nil? ? model : @scope.call end
# File lib/thinking_sphinx/real_time/index.rb, line 50 def unique_attribute_names attributes.collect(&:name) end
# File lib/thinking_sphinx/real_time/index.rb, line 56 def append_unique_attribute(collection, attribute) collection << attribute.name unless collection.include?(attribute.name) end
# File lib/thinking_sphinx/real_time/index.rb, line 60 def collection_for(attribute) case attribute.type when :integer, :boolean attribute.multi? ? @rt_attr_multi : @rt_attr_uint when :string @rt_attr_string when :timestamp @rt_attr_timestamp when :float @rt_attr_float else raise "Unknown attribute type '#{attribute.type}'" end end
# File lib/thinking_sphinx/real_time/index.rb, line 75 def interpreter ThinkingSphinx::RealTime::Interpreter end
# File lib/thinking_sphinx/real_time/index.rb, line 79 def pre_render super @rt_field = fields.collect &:name attributes.each do |attribute| append_unique_attribute collection_for(attribute), attribute end end
# File lib/thinking_sphinx/real_time/index.rb, line 89 def properties fields + attributes end