class PactBroker::Tags::EagerLoaders::HeadTag
Public Class Methods
call(eo, **_other)
click to toggle source
# File lib/pact_broker/tags/eager_loaders.rb, line 5 def self.call(eo, **_other) initialize_association(eo[:rows]) populate_associations(eo[:rows]) end
group_by_pacticipant_id(tags)
click to toggle source
# File lib/pact_broker/tags/eager_loaders.rb, line 20 def self.group_by_pacticipant_id(tags) tags.to_a.group_by(&:pacticipant_id) end
initialize_association(tags)
click to toggle source
# File lib/pact_broker/tags/eager_loaders.rb, line 10 def self.initialize_association(tags) tags.each{|tag| tag.associations[:head_tag] = nil } end
populate_associations(tags)
click to toggle source
# File lib/pact_broker/tags/eager_loaders.rb, line 14 def self.populate_associations(tags) group_by_pacticipant_id(tags).each do | pacticipant_id, participant_tags | populate_associations_by_pacticipant(pacticipant_id, participant_tags) end end
populate_associations_by_pacticipant(pacticipant_id, tags)
click to toggle source
# File lib/pact_broker/tags/eager_loaders.rb, line 24 def self.populate_associations_by_pacticipant(pacticipant_id, tags) latest_tags_for_tags = latest_tags_for_pacticipant_id( pacticipant_id, tags.collect(&:name).uniq.compact, tags.first.class ) self.populate_tags(tags, latest_tags_for_tags) end