Class: ThinkingSphinx::Deltas::DefaultDelta
- Inherits:
-
Object
- Object
- ThinkingSphinx::Deltas::DefaultDelta
- Defined in:
- lib/thinking_sphinx/deltas/default_delta.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
Instance Method Summary collapse
- #clause(model, toggled) ⇒ Object
- #index(model, instance = nil) ⇒ Object
-
#initialize(index, options) ⇒ DefaultDelta
constructor
A new instance of DefaultDelta.
- #reset_query(model) ⇒ Object
- #toggle(instance) ⇒ Object
- #toggled(instance) ⇒ Object
Constructor Details
#initialize(index, options) ⇒ DefaultDelta
Returns a new instance of DefaultDelta.
6 7 8 9 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 6 def initialize(index, ) @index = index @column = .delete(:delta_column) || :delta end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
4 5 6 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 4 def column @column end |
Instance Method Details
#clause(model, toggled) ⇒ Object
36 37 38 39 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 36 def clause(model, toggled) "#{model.quoted_table_name}.#{model.connection.quote_column_name(@column.to_s)}" + " = #{adapter.boolean(toggled)}" end |
#index(model, instance = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 11 def index(model, instance = nil) return true unless ThinkingSphinx.updates_enabled? && ThinkingSphinx.deltas_enabled? return true if instance && !toggled(instance) update_delta_indexes model delete_from_core model, instance if instance true end |
#reset_query(model) ⇒ Object
30 31 32 33 34 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 30 def reset_query(model) "UPDATE #{model.quoted_table_name} SET " + "#{model.connection.quote_column_name(@column.to_s)} = #{adapter.boolean(false)} " + "WHERE #{model.connection.quote_column_name(@column.to_s)} = #{adapter.boolean(true)}" end |
#toggle(instance) ⇒ Object
22 23 24 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 22 def toggle(instance) instance.delta = true end |
#toggled(instance) ⇒ Object
26 27 28 |
# File 'lib/thinking_sphinx/deltas/default_delta.rb', line 26 def toggled(instance) instance.delta end |