Sha256: 71b28b0c2c19a7c7e7f1bff484734b806d8926e68d0f4556738c6642e3abf932

Contents?: true

Size: 654 Bytes

Versions: 13

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require "rack"

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

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

      def call _omit = nil
        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

13 entries across 13 versions & 1 rubygems

Version Path
pennyworth-14.1.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-14.1.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-14.0.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.8.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.7.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.6.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.5.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.4.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.3.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.2.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.1.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.0.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-13.0.0 lib/pennyworth/loaders/http_statuses.rb