Sha256: 4d96109e599e554ad1d6d9880d5a631bdad6244b0efac6d7d523faea8b497c09

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Vigiles
  module Archive
    extend T::Sig

    Types       = Vigiles::Types
    ContentType = Types::ContentType

    class UnrecordableRequestError < StandardError
      sig { params(reason: String).void }
      def initialize(reason)
        @reason = reason
        super
      end
    end

    sig { params(req: ActionDispatch::Request, res: Rack::Response).returns(T.nilable(Conversation)) }
    def self.record_conversation(req:, res:)
      content_type = req.content_type
      if (recorder = Vigiles.spec.recorders[content_type]).nil?
        raise \
          UnrecordableRequestError,
          "no recorder configured for content type: #{content_type}"
      end

      recorder.record(req:, res:)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vigiles-0.1.5 lib/vigiles/archive.rb
vigiles-0.1.4 lib/vigiles/archive.rb