Sha256: 1ac2d09041c5bb1a7752bf4978e59d5ba0f2b5cdae8a595119b1555908bd96f2

Contents?: true

Size: 529 Bytes

Versions: 1

Compression:

Stored size: 529 Bytes

Contents

# frozen_string_literal: true

module Lecter
  class FormatterHeaders
    WRONG_HEADERS_MSG = 'Wrong headers'
    attr_reader :result, :error_message

    def initialize(headers)
      @dirty_headers = headers
    end

    def call
      @result = dirty_headers
                .split(',')
                .map { |header_with_value| header_with_value.split('=') }
                .to_h
    rescue StandardError
      @error_message = WRONG_HEADERS_MSG
      false
    end

    private

    attr_accessor :dirty_headers
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lecter-0.2.0 lib/lecter/formatter_headers.rb