Sha256: b4208614ecf1cdba1f5bb391200cf62d47daac68b06cb5024f96a698d16241a5

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'roar/representer/json/hal'
require_relative 'pact_broker_urls'
require_relative 'version_representor'

module Roar
  module Representer
    module Feature

      module Hypermedia

        #Monkey patch alert! Get "no method rel for Nil" when there is an empty array
        #in links. Cannot reproduce this in the roar tests :(
        alias_method :original_compile_links_for, :compile_links_for

        def compile_links_for configs, *args
          original_compile_links_for(configs, *args).select(&:any?)
        end

      end
    end
  end
end


module PactBroker

  module Api

    module Representors

      module PacticipantCollectionRepresenter
        include Roar::Representer::JSON::HAL
        include PactBroker::Api::PactBrokerUrls


        collection :pacticipants, :class => PactBroker::Models::Pacticipant, :extend => PactBroker::Api::Representors::PacticipantRepresenter

        def pacticipants
          self
        end

        link :self do
          pacticipants_url
        end

        links :pacticipants do
          collect{ | pacticipant | {:href => pacticipant_url(pacticipant), :name => pacticipant.name } }
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-0.0.5 lib/pact_broker/api/representors/pacticipant_collection_representor.rb