Sha256: bcb313222a72fce83ee2326eec9453924acc6ac3d7e24c17062be3a775a1246a

Contents?: true

Size: 578 Bytes

Versions: 7

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

require "rack"

module Pennyworth
  module Loaders
    # Loads an array of HTTP status records.
    class HTTPStatus
      include Import[:configuration]

      def initialize(codes: Rack::Utils::HTTP_STATUS_CODES, model: Models::HTTPStatus, **)
        super(**)
        @codes = codes
        @model = model
      end

      def call(*)
        codes.map { |(code, label)| model[code:, label:, url: "#{url}/#{code}"] }
      end

      private

      attr_reader :codes, :model

      def url = configuration.http_statuses_url
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pennyworth-16.7.0 lib/pennyworth/loaders/http_status.rb
pennyworth-16.5.0 lib/pennyworth/loaders/http_status.rb
pennyworth-16.4.0 lib/pennyworth/loaders/http_status.rb
pennyworth-16.3.0 lib/pennyworth/loaders/http_status.rb
pennyworth-16.2.0 lib/pennyworth/loaders/http_status.rb
pennyworth-16.1.0 lib/pennyworth/loaders/http_status.rb
pennyworth-16.0.0 lib/pennyworth/loaders/http_status.rb