Class: ActiverecordReindex::Reindexer
- Inherits:
-
Object
- Object
- ActiverecordReindex::Reindexer
- Defined in:
- lib/activerecord_reindex/reindexer.rb
Instance Method Summary collapse
-
#call(record, reflection:, skip_record:) ⇒ Object
reindex records associated with given record on given association if association is collection(has_many, has_many_through, has_and_belongs_to_many) get all associated recrods and reindex them else reindex given record associted one.
-
#with_strategy(strategy) ⇒ Object
chain strategy before actual executing strategy can be either sync or async corresponding to type of reindexing additional strategies can be defined and specified by user.
Instance Method Details
#call(record, reflection:, skip_record:) ⇒ Object
reindex records associated with given record on given association if association is collection(has_many, has_many_through, has_and_belongs_to_many)
get all associated recrods and reindex them
else
reindex given record associted one
20 21 22 23 24 25 26 27 28 |
# File 'lib/activerecord_reindex/reindexer.rb', line 20 def call(record, reflection:, skip_record:) if reflection.collection? _reindex_collection(reflection, record, skip_record) else associated_record = record.public_send(reflection.name) return if associated_record == skip_record _update_index(associated_record, record) end end |
#with_strategy(strategy) ⇒ Object
chain strategy before actual executing strategy can be either sync or async corresponding to type of reindexing additional strategies can be defined and specified by user
10 11 12 13 |
# File 'lib/activerecord_reindex/reindexer.rb', line 10 def with_strategy(strategy) @strategy = strategy self end |