Class: PactBroker::Versions::EagerLoaders::LatestVersionForPacticipant
- Inherits:
-
Object
- Object
- PactBroker::Versions::EagerLoaders::LatestVersionForPacticipant
- Defined in:
- lib/pact_broker/versions/eager_loaders.rb
Class Method Summary collapse
- .call(eo, **other) ⇒ Object
- .group_by_pacticipant(versions) ⇒ Object
- .populate_associations(versions) ⇒ Object
- .populate_associations_by_pacticipant(pacticipant, versions) ⇒ Object
Class Method Details
.call(eo, **other) ⇒ Object
47 48 49 |
# File 'lib/pact_broker/versions/eager_loaders.rb', line 47 def self.call(eo, **other) populate_associations(eo[:rows]) end |
.group_by_pacticipant(versions) ⇒ Object
57 58 59 |
# File 'lib/pact_broker/versions/eager_loaders.rb', line 57 def self.group_by_pacticipant(versions) versions.to_a.group_by(&:pacticipant) end |
.populate_associations(versions) ⇒ Object
51 52 53 54 55 |
# File 'lib/pact_broker/versions/eager_loaders.rb', line 51 def self.populate_associations(versions) group_by_pacticipant(versions).each do | pacticipant, versions | populate_associations_by_pacticipant(pacticipant, versions) end end |
.populate_associations_by_pacticipant(pacticipant, versions) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/pact_broker/versions/eager_loaders.rb', line 61 def self.populate_associations_by_pacticipant(pacticipant, versions) latest_version = versions.first.class.latest_version_for_pacticipant(pacticipant).single_record versions.each do | version | version.associations[:latest_version_for_pacticipant] = latest_version end end |