Class: ThinkingSphinx::Source
- Inherits:
-
Object
- Object
- ThinkingSphinx::Source
- Includes:
- InternalProperties, SQL
- Defined in:
- lib/thinking_sphinx/source.rb,
lib/thinking_sphinx/source/sql.rb,
lib/thinking_sphinx/source/internal_properties.rb
Defined Under Namespace
Modules: InternalProperties, SQL
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#database_configuration ⇒ Object
readonly
Returns the value of attribute database_configuration.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#groupings ⇒ Object
Returns the value of attribute groupings.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#model ⇒ Object
Returns the value of attribute model.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#association(key) ⇒ Object
Gets the association stack for a specific key.
- #delta? ⇒ Boolean
-
#initialize(index, options = {}) ⇒ Source
constructor
A new instance of Source.
- #name ⇒ Object
- #to_riddle_for_core(offset, position) ⇒ Object
- #to_riddle_for_delta(offset, position) ⇒ Object
Methods included from SQL
#crc_column, #quote_column, #sql_group_clause, #sql_query_pre_for_core, #sql_query_pre_for_delta, #sql_select_clause, #sql_where_clause, #to_sql, #to_sql_query_info, #to_sql_query_range
Methods included from InternalProperties
#add_internal_attribute, #add_internal_attributes_and_facets, #add_internal_facet, #attribute_by_alias, #facet_by_alias, #subclasses_to_s
Constructor Details
#initialize(index, options = {}) ⇒ Source
Returns a new instance of Source.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/thinking_sphinx/source.rb', line 13 def initialize(index, = {}) @index = index @model = index.model @fields = [] @attributes = [] @conditions = [] @groupings = [] @options = @associations = {} @database_configuration = @model.connection. instance_variable_get(:@config).clone @base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new( @model, [], nil ) unless @model.descends_from_active_record? stored_class = @model.store_full_sti_class ? @model.name : @model.name.demodulize @conditions << "#{@model.quoted_table_name}.#{quote_column(@model.inheritance_column)} = '#{stored_class}'" end add_internal_attributes_and_facets end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def attributes @attributes end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
11 12 13 |
# File 'lib/thinking_sphinx/source.rb', line 11 def base @base end |
#conditions ⇒ Object
Returns the value of attribute conditions.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def conditions @conditions end |
#database_configuration ⇒ Object (readonly)
Returns the value of attribute database_configuration.
11 12 13 |
# File 'lib/thinking_sphinx/source.rb', line 11 def database_configuration @database_configuration end |
#fields ⇒ Object
Returns the value of attribute fields.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def fields @fields end |
#groupings ⇒ Object
Returns the value of attribute groupings.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def groupings @groupings end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
11 12 13 |
# File 'lib/thinking_sphinx/source.rb', line 11 def index @index end |
#model ⇒ Object
Returns the value of attribute model.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def model @model end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def @options end |
Instance Method Details
#association(key) ⇒ Object
Gets the association stack for a specific key.
74 75 76 |
# File 'lib/thinking_sphinx/source.rb', line 74 def association(key) @associations[key] ||= Association.children(@model, key) end |
#delta? ⇒ Boolean
68 69 70 |
# File 'lib/thinking_sphinx/source.rb', line 68 def delta? !@index.delta_object.nil? end |
#name ⇒ Object
37 38 39 |
# File 'lib/thinking_sphinx/source.rb', line 37 def name index.name end |
#to_riddle_for_core(offset, position) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/thinking_sphinx/source.rb', line 41 def to_riddle_for_core(offset, position) source = Riddle::Configuration::SQLSource.new( "#{index.core_name}_#{position}", adapter.sphinx_identifier ) set_source_database_settings source set_source_attributes source, offset set_source_settings source set_source_sql source, offset source end |
#to_riddle_for_delta(offset, position) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/thinking_sphinx/source.rb', line 54 def to_riddle_for_delta(offset, position) source = Riddle::Configuration::SQLSource.new( "#{index.delta_name}_#{position}", adapter.sphinx_identifier ) source.parent = "#{index.core_name}_#{position}" set_source_database_settings source set_source_attributes source, offset, true set_source_settings source set_source_sql source, offset, true source end |