Module: ThinkingSphinx::Core::Index
- Extended by:
- ActiveSupport::Concern
- Includes:
- Settings
- Included in:
- ActiveRecord::Index, RealTime::Index
- Defined in:
- lib/thinking_sphinx/core/index.rb
Instance Method Summary collapse
- #delta? ⇒ Boolean
- #distributed? ⇒ Boolean
- #document_id_for_instance(instance) ⇒ Object
- #document_id_for_key(key) ⇒ Object
- #initialize(reference, options = {}) ⇒ Object
- #interpret_definition! ⇒ Object
- #model ⇒ Object
- #options ⇒ Object
- #primary_key ⇒ Object
- #render ⇒ Object
Instance Method Details
#delta? ⇒ Boolean
21 22 23 |
# File 'lib/thinking_sphinx/core/index.rb', line 21 def delta? false end |
#distributed? ⇒ Boolean
25 26 27 |
# File 'lib/thinking_sphinx/core/index.rb', line 25 def distributed? false end |
#document_id_for_instance(instance) ⇒ Object
29 30 31 |
# File 'lib/thinking_sphinx/core/index.rb', line 29 def document_id_for_instance(instance) document_id_for_key instance.public_send(primary_key) end |
#document_id_for_key(key) ⇒ Object
33 34 35 36 37 |
# File 'lib/thinking_sphinx/core/index.rb', line 33 def document_id_for_key(key) return nil if key.nil? key * config.indices.count + offset end |
#initialize(reference, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/thinking_sphinx/core/index.rb', line 12 def initialize(reference, = {}) @reference = reference.to_sym @options = @offset = config.next_offset([:offset_as] || reference) @type = 'plain' super "#{[:name] || reference.to_s.gsub('/', '_')}_#{name_suffix}" end |
#interpret_definition! ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/thinking_sphinx/core/index.rb', line 39 def interpret_definition! table_exists = model.table_exists? unless table_exists Rails.logger.info "No table exists for #{model}. Index can not be created" return end return if @interpreted_definition apply_defaults! @interpreted_definition = true interpreter.translate! self, @definition_block if @definition_block end |
#model ⇒ Object
53 54 55 |
# File 'lib/thinking_sphinx/core/index.rb', line 53 def model @model ||= reference.to_s.camelize.constantize end |
#options ⇒ Object
57 58 59 60 |
# File 'lib/thinking_sphinx/core/index.rb', line 57 def interpret_definition! @options end |
#primary_key ⇒ Object
62 63 64 65 |
# File 'lib/thinking_sphinx/core/index.rb', line 62 def primary_key @primary_key ||= @options[:primary_key] || config.settings['primary_key'] || model.primary_key || :id end |
#render ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/thinking_sphinx/core/index.rb', line 67 def render pre_render set_path assign_infix_fields assign_prefix_fields super end |