class PactBroker::Api::Decorators::LabelDecorator

Public Instance Methods

to_hash(options) click to toggle source

This method is overridden to conditionally render the links based on the user_options

Calls superclass method
# File lib/pact_broker/api/decorators/label_decorator.rb, line 15
def to_hash(options)
  hash = super

  unless options.dig(:user_options, :hide_label_decorator_links)
    hash[:_links] = {
      self: {
        title: "Label",
        name: represented.name,
        href: label_url(represented, options.dig(:user_options, :base_url))
      },
      pacticipant: {
        title: "Pacticipant",
        name: represented.pacticipant.name,
        href: pacticipant_url(options.dig(:user_options, :base_url), represented.pacticipant)
      }
    }
  end

  hash
end