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.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#groupings ⇒ Object
Returns the value of attribute groupings.
-
#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, index) ⇒ Object
- #to_riddle_for_delta(offset, index) ⇒ 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 |
# File 'lib/thinking_sphinx/source.rb', line 13 def initialize(index, = {}) @index = index @model = index.model @fields = [] @attributes = [] @conditions = [] @groupings = [] @options = @associations = {} @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 |
#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 |
#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.
71 72 73 |
# File 'lib/thinking_sphinx/source.rb', line 71 def association(key) @associations[key] ||= Association.children(@model, key) end |
#delta? ⇒ Boolean
65 66 67 |
# File 'lib/thinking_sphinx/source.rb', line 65 def delta? !@index.delta_object.nil? end |
#name ⇒ Object
35 36 37 |
# File 'lib/thinking_sphinx/source.rb', line 35 def name @model.name.underscore.tr(':/\\', '_') end |
#to_riddle_for_core(offset, index) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/thinking_sphinx/source.rb', line 39 def to_riddle_for_core(offset, index) source = Riddle::Configuration::SQLSource.new( "#{name}_core_#{index}", adapter.sphinx_identifier ) set_source_database_settings source set_source_attributes source, offset set_source_sql source, offset set_source_settings source source end |
#to_riddle_for_delta(offset, index) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/thinking_sphinx/source.rb', line 52 def to_riddle_for_delta(offset, index) source = Riddle::Configuration::SQLSource.new( "#{name}_delta_#{index}", adapter.sphinx_identifier ) source.parent = "#{name}_core_#{index}" set_source_database_settings source set_source_attributes source, offset set_source_sql source, offset, true source end |