Sha256: 72d56c3ee448463314da3448833ddccb7acff05383666647b90eab5ed1475aad

Contents?: true

Size: 908 Bytes

Versions: 40

Compression:

Stored size: 908 Bytes

Contents

module PactBroker
  module Versions
    module EagerLoaders
      class LatestVersionForPacticipant
        def self.call(eo, **_other)
          populate_associations(eo[:rows])
        end

        def self.populate_associations(versions)
          group_by_pacticipant(versions).each do | pacticipant, participant_versions |
            populate_associations_by_pacticipant(pacticipant, participant_versions)
          end
        end

        def self.group_by_pacticipant(versions)
          versions.to_a.group_by(&:pacticipant)
        end

        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
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.111.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.109.1 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.109.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.108.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.107.1 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.107.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.106.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.105.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.104.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.103.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.102.2 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.102.1 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.102.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.101.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.100.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.99.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.98.0 lib/pact_broker/versions/eager_loaders.rb
pact_broker-2.97.0 lib/pact_broker/versions/eager_loaders.rb