class PactBroker::Api::Decorators::VersionDecorator

Public Class Methods

eager_load_associations() click to toggle source

Returns the list of associations that must be eager loaded to efficiently render a version when this decorator is used in a collection (eg. VersionsDecorator) The associations that need to be eager loaded for the VersionDecorator are hand coded @return <Array>

# File lib/pact_broker/api/decorators/version_decorator.rb, line 25
def self.eager_load_associations
  [
    :pacticipant,
    :pact_publications,
    { branch_versions: [:version, :branch_head, { branch: :pacticipant }] },
    { tags: :head_tag }
  ]
end

Public Instance Methods

from_hash(hash, options = {}) click to toggle source
Calls superclass method
# File lib/pact_broker/api/decorators/version_decorator.rb, line 104
def from_hash(hash, options = {})
  if hash["tags"]
    updated_hash = hash.dup
    updated_hash["_embedded"] ||= {}
    updated_hash["_embedded"]["tags"] = updated_hash.delete("tags")
    super(updated_hash, options)
  else
    super
  end
end

Private Instance Methods

sorted_pacts() click to toggle source
# File lib/pact_broker/api/decorators/version_decorator.rb, line 117
def sorted_pacts
  represented.pact_publications.sort{ |a, b| a.provider_name.downcase <=> b.provider_name.downcase }
end