Class: ThinkingSphinx::ActiveRecord::SQLSource
- Inherits:
-
Riddle::Configuration::SQLSource
- Object
- Riddle::Configuration::SQLSource
- ThinkingSphinx::ActiveRecord::SQLSource
- Includes:
- Core::Settings
- Defined in:
- lib/thinking_sphinx/active_record/sql_source.rb
Defined Under Namespace
Classes: Template
Constant Summary collapse
- OPTIONS =
[:name, :offset, :delta_processor, :delta?, :disable_range?, :group_concat_max_len, :utf8?, :position]
Instance Attribute Summary collapse
-
#associations ⇒ Object
Returns the value of attribute associations.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#database_settings ⇒ Object
readonly
Returns the value of attribute database_settings.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#groupings ⇒ Object
Returns the value of attribute groupings.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#polymorphs ⇒ Object
Returns the value of attribute polymorphs.
Instance Method Summary collapse
- #adapter ⇒ Object
- #delta? ⇒ Boolean
- #delta_processor ⇒ Object
- #disable_range? ⇒ Boolean
- #facets ⇒ Object
-
#initialize(model, options = {}) ⇒ SQLSource
constructor
A new instance of SQLSource.
- #offset ⇒ Object
- #primary_key ⇒ Object
- #render ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(model, options = {}) ⇒ SQLSource
Returns a new instance of SQLSource.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 12 def initialize(model, = {}) @model = model @database_settings = ::ActiveRecord::Base.connection. instance_variable_get(:@config).clone = { :utf8? => (@database_settings[:encoding] == 'utf8') }.merge @fields = [] @attributes = [] @associations = [] @conditions = [] @groupings = [] @polymorphs = [] Template.new(self).apply name = "#{options[:name] || model.name.downcase}_#{options[:position]}" super name, type apply_defaults! end |
Instance Attribute Details
#associations ⇒ Object
Returns the value of attribute associations.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 6 def associations @associations end |
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 6 def attributes @attributes end |
#conditions ⇒ Object
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 6 def conditions @conditions end |
#database_settings ⇒ Object (readonly)
Returns the value of attribute database_settings.
5 6 7 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 5 def database_settings @database_settings end |
#fields ⇒ Object
Returns the value of attribute fields.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 6 def fields @fields end |
#groupings ⇒ Object
Returns the value of attribute groupings.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 6 def groupings @groupings end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 5 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 5 def end |
#polymorphs ⇒ Object
Returns the value of attribute polymorphs.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 6 def polymorphs @polymorphs end |
Instance Method Details
#adapter ⇒ Object
36 37 38 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 36 def adapter @adapter ||= DatabaseAdapters.adapter_for(@model) end |
#delta? ⇒ Boolean
44 45 46 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 44 def delta? [:delta?] end |
#delta_processor ⇒ Object
40 41 42 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 40 def delta_processor [:delta_processor].try(:new, adapter) end |
#disable_range? ⇒ Boolean
48 49 50 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 48 def disable_range? [:disable_range?] end |
#facets ⇒ Object
52 53 54 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 52 def facets properties.select(&:facet?) end |
#offset ⇒ Object
56 57 58 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 56 def offset [:offset] end |
#primary_key ⇒ Object
60 61 62 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 60 def primary_key [:primary_key] end |
#render ⇒ Object
64 65 66 67 68 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 64 def render prepare_for_render unless @prepared super end |
#type ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/thinking_sphinx/active_record/sql_source.rb', line 70 def type @type ||= case adapter when DatabaseAdapters::MySQLAdapter 'mysql' when DatabaseAdapters::PostgreSQLAdapter 'pgsql' else raise "Unknown Adapter Type: #{adapter.class.name}" end end |