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.
-
#joins ⇒ Object
Returns the value of attribute joins.
-
#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, #type_values, #types_to_crcs
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 36 |
# File 'lib/thinking_sphinx/source.rb', line 13 def initialize(index, = {}) @index = index @model = index.model @fields = [] @attributes = [] @joins = [] @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 |
#joins ⇒ Object
Returns the value of attribute joins.
9 10 11 |
# File 'lib/thinking_sphinx/source.rb', line 9 def joins @joins 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.
75 76 77 |
# File 'lib/thinking_sphinx/source.rb', line 75 def association(key) @associations[key] ||= Association.children(@model, key) end |
#delta? ⇒ Boolean
69 70 71 |
# File 'lib/thinking_sphinx/source.rb', line 69 def delta? !@index.delta_object.nil? end |
#name ⇒ Object
38 39 40 |
# File 'lib/thinking_sphinx/source.rb', line 38 def name index.name end |
#to_riddle_for_core(offset, position) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/thinking_sphinx/source.rb', line 42 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
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/thinking_sphinx/source.rb', line 55 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 |