Class: SyncMachine::FindSubjectsWorker::Hook
- Inherits:
-
Object
- Object
- SyncMachine::FindSubjectsWorker::Hook
- Defined in:
- lib/sync_machine/find_subjects_worker.rb
Overview
Wrap a “subject_ids_from_*” block.
Instance Method Summary collapse
- #call(record, changed_keys) ⇒ Object
-
#initialize(name, sync_module, block) ⇒ Hook
constructor
A new instance of Hook.
Constructor Details
#initialize(name, sync_module, block) ⇒ Hook
Returns a new instance of Hook.
65 66 67 68 69 |
# File 'lib/sync_machine/find_subjects_worker.rb', line 65 def initialize(name, sync_module, block) @name = name.to_s @sync_module = sync_module @block = block end |
Instance Method Details
#call(record, changed_keys) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/sync_machine/find_subjects_worker.rb', line 71 def call(record, changed_keys) TracerAdapters.tracer_adapter.start_active_span(@name) do raw_source_ids = if @block.arity == 2 @block.call(record, changed_keys) else @block.call(record) end Array.wrap(raw_source_ids).map { |raw_source_id| @sync_module.orm_adapter.record_id_for_job(raw_source_id) } end end |