Sha256: 999d8ac6f87be094e8792e9c5799b2caf0f206ff3c817eb7c843afe03e0531f6

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

require_relative "base_decorator"
require_relative "pact_pacticipant_decorator"
require_relative "timestamps"

module PactBroker
  module Api
    module Decorators
      class LabelDecorator < BaseDecorator

        property :name

        include Timestamps

        # This method is overridden to conditionally render the links based on the user_options
        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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pact_broker-2.114.0 lib/pact_broker/api/decorators/label_decorator.rb
pact_broker-2.113.2 lib/pact_broker/api/decorators/label_decorator.rb
pact_broker-2.113.1 lib/pact_broker/api/decorators/label_decorator.rb
pact_broker-2.113.0 lib/pact_broker/api/decorators/label_decorator.rb
pact_broker-2.112.0 lib/pact_broker/api/decorators/label_decorator.rb
pact_broker-2.111.0 lib/pact_broker/api/decorators/label_decorator.rb