Sha256: ca7586d88ae92bad89cce60dd0fc5ef29305b916584b04cd142123551eae7406

Contents?: true

Size: 589 Bytes

Versions: 14

Compression:

Stored size: 589 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, **)
        super(**)
        @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

14 entries across 14 versions & 1 rubygems

Version Path
pennyworth-15.4.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.4.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.3.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.2.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.1.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.1.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.0.3 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.0.2 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.0.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-15.0.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-14.3.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-14.2.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-14.2.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-14.1.2 lib/pennyworth/loaders/http_statuses.rb