Class: Chewy::Strategy::Base
- Inherits:
-
Object
- Object
- Chewy::Strategy::Base
- Defined in:
- lib/chewy/strategy/base.rb
Overview
This strategy raises exception on every index update asking to choose some other strategy.
Chewy.strategy(:base) do User.all.map(&:save) # Raises UndefinedUpdateStrategy exception end
Instance Method Summary collapse
-
#leave ⇒ Object
This method called when strategy pops from the strategies stack.
- #name ⇒ Object
-
#update(type, _objects, _options = {}) ⇒ Object
This method called when some model tries to update index.
-
#update_chewy_indices(object) ⇒ Object
This method called when some model record is created or updated.
Instance Method Details
#leave ⇒ Object
This method called when strategy pops from the strategies stack
24 |
# File 'lib/chewy/strategy/base.rb', line 24 def leave; end |
#name ⇒ Object
11 12 13 |
# File 'lib/chewy/strategy/base.rb', line 11 def name self.class.name.demodulize.underscore.to_sym end |
#update(type, _objects, _options = {}) ⇒ Object
This method called when some model tries to update index
17 18 19 |
# File 'lib/chewy/strategy/base.rb', line 17 def update(type, _objects, = {}) raise UndefinedUpdateStrategy, type end |
#update_chewy_indices(object) ⇒ Object
This method called when some model record is created or updated. Normally it will just evaluate all the Chewy callbacks and pass results to current strategy's update method. However it's possible to override it to achieve delayed evaluation of callbacks, e.g. using sidekiq.
32 33 34 |
# File 'lib/chewy/strategy/base.rb', line 32 def update_chewy_indices(object) object.run_chewy_callbacks end |