Module: Shared::TaxonDeterminationsOtuWatcher
- Extended by:
- ActiveSupport::Concern
- Included in:
- TaxonDetermination
- Defined in:
- app/models/concerns/shared/taxon_determinations_otu_watcher.rb
Overview
Detects when a TaxonDetermination change alters the parent object’s accepted OTU, and alerts the taxon_determination_object.
Instance Method Summary collapse
Instance Method Details
#capture_previous_top_otu_id ⇒ Object (private)
18 19 20 21 22 |
# File 'app/models/concerns/shared/taxon_determinations_otu_watcher.rb', line 18 def capture_previous_top_otu_id obj = taxon_determination_object self._prev_top_otu_id = obj.respond_to?(:current_otu) ? obj.current_otu&.id : nil true end |
#propagate_if_top_otu_changed ⇒ Object (private)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/concerns/shared/taxon_determinations_otu_watcher.rb', line 24 def propagate_if_top_otu_changed obj = taxon_determination_object return true unless obj && obj.respond_to?(:propagate_current_otu_change!) new_id = obj.respond_to?(:current_otu) ? obj.current_otu&.id : nil old_id = _prev_top_otu_id return true if old_id == new_id obj.propagate_current_otu_change!(from_id: old_id, to_id: new_id) true rescue => e Rails.logger.warn("OtuWatcher for TaxonDetermination##{id} failed: #{e.class}: #{e.}") false end |