Module: Warren::Callback::ExceptExternallyManaged
- Included in:
- ApplicationRecord
- Defined in:
- lib/warren/callback/except_externally_managed.rb
Overview
Provides Warren broadcasting helpers that exclude records that are externally managed.
Including this module adds:
- ClassMethods#broadcast_with_warren_except_externally_managed for configuring automatic broadcasts after commit.
- #broadcast_except_externally_managed for manually broadcasting records while applying the externally managed filter.
Records are considered externally managed when they respond to
externally_managed? and the predicate returns true.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ void
Extends the including class with the class methods.
Instance Method Summary collapse
-
#broadcast_except_externally_managed ⇒ void
Broadcasts the record as a Warren full message unless it is externally managed.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Extends the including class with the class methods.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/warren/callback/except_externally_managed.rb', line 36 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
Instance Method Details
#broadcast_except_externally_managed ⇒ void
This method returns an undefined value.
Broadcasts the record as a Warren full message unless it is externally managed.
Records that implement externally_managed? and return true are
ignored.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/warren/callback/except_externally_managed.rb', line 46 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |