Class: ThinkingSphinx::Deltas::DefaultDelta
- Inherits:
-
Object
- Object
- ThinkingSphinx::Deltas::DefaultDelta
- Defined in:
- lib/thinking_sphinx/deltas/default_delta.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #clause(delta_source = false) ⇒ Object
- #delete(index, instance) ⇒ Object
- #index(index) ⇒ Object
-
#initialize(adapter, options = {}) ⇒ DefaultDelta
constructor
A new instance of DefaultDelta.
- #reset_query ⇒ Object
- #toggle(instance) ⇒ Object
- #toggled?(instance) ⇒ Boolean
Constructor Details
#initialize(adapter, options = {}) ⇒ DefaultDelta
Returns a new instance of DefaultDelta.
6 7 8 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 6 def initialize(adapter, = {}) @adapter, @options = adapter, end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
4 5 6 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 4 def adapter @adapter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 4 def @options end |
Instance Method Details
#clause(delta_source = false) ⇒ Object
10 11 12 13 14 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 10 def clause(delta_source = false) return nil unless delta_source "#{adapter.quoted_table_name}.#{quoted_column} = #{adapter.boolean_value delta_source}" end |
#delete(index, instance) ⇒ Object
16 17 18 19 20 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 16 def delete(index, instance) ThinkingSphinx::Deltas::DeleteJob.new( index.name, index.document_id_for_instance(instance) ).perform end |
#index(index) ⇒ Object
22 23 24 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 22 def index(index) ThinkingSphinx::Deltas::IndexJob.new(index.name).perform end |
#reset_query ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 26 def reset_query (<<-SQL).strip.gsub(/\n\s*/, ' ') UPDATE #{adapter.quoted_table_name} SET #{quoted_column} = #{adapter.boolean_value false} WHERE #{quoted_column} = #{adapter.boolean_value true} SQL end |
#toggle(instance) ⇒ Object
34 35 36 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 34 def toggle(instance) instance.send "#{column}=", true end |
#toggled?(instance) ⇒ Boolean
38 39 40 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 38 def toggled?(instance) instance.send "#{column}?" end |