Sha256: b1b928eb13373ad6f01a6269b7c45eaae1eabd227f064ad816eb36adc8166e4b

Contents?: true

Size: 1.39 KB

Versions: 25

Compression:

Stored size: 1.39 KB

Contents

require 'pact_broker/api/resources/base_resource'
require 'pact_broker/api/decorators/matrix_decorator'
require 'pact_broker/api/decorators/matrix_text_decorator'
require 'pact_broker/matrix/parse_query'

module PactBroker
  module Api
    module Resources
      class Matrix < BaseResource

        def initialize
          @selectors, @options = PactBroker::Matrix::ParseQuery.call(request.uri.query)
        end

        def content_types_provided
          [
            ["application/hal+json", :to_json],
            ["text/plain", :to_text]
          ]
        end

        def allowed_methods
          ["GET"]
        end

        def malformed_request?
          error_messages = matrix_service.validate_selectors(selectors)
          if error_messages.any?
            set_json_validation_error_messages error_messages
            true
          else
            false
          end
        end

        def to_json
          PactBroker::Api::Decorators::MatrixDecorator.new(lines).to_json(user_options: { base_url: base_url })
        end

        def to_text
          PactBroker::Api::Decorators::MatrixTextDecorator.new(lines).to_text(user_options: { base_url: base_url })
        end

        def lines
          @lines ||= matrix_service.find(selectors, options)
        end

        def selectors
          @selectors
        end

        def options
          @options
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
pact_broker-2.23.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.22.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.21.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.20.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.19.2 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.19.1 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.19.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.18.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.17.1 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.17.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.16.1 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.16.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.15.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.14.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.13.1 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.13.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.12.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.11.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.10.0 lib/pact_broker/api/resources/matrix.rb
pact_broker-2.9.0 lib/pact_broker/api/resources/matrix.rb