Sha256: 9adf254da80c183e94e4b5fc7edd8cdb1afbc4e75f5a5e50296129e17c563033

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module Inferno
  module Entities
    # A `Header` represents an HTTP request/response header
    #
    # @attr_accessor [String] id of the header
    # @attr_accessor [String] request_id index of the HTTP request
    # @attr_accessor [String] name header name
    # @attr_accessor [String] value header value
    # @attr_accessor [String] type request/response
    # @attr_accessor [Time] created_at
    # @attr_accessor [Time] updated_at
    class Header < Entity
      ATTRIBUTES = [:id, :request_id, :name, :type, :value, :created_at, :updated_at].freeze

      include Inferno::Entities::Attributes

      def initialize(params)
        super(params, ATTRIBUTES)
      end

      def request?
        type == 'request'
      end

      def response?
        type == 'response'
      end

      def to_hash
        {
          id: id,
          request_id: request_id,
          type: type,
          name: name,
          value: value,
          created_at: created_at,
          updated_at: updated_at
        }.compact
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
inferno_core-0.0.6 lib/inferno/entities/header.rb
inferno_core-0.0.5 lib/inferno/entities/header.rb
inferno_core-0.0.4 lib/inferno/entities/header.rb