Sha256: 381d8faa029e06f1760129f262113e4ecf929f79b7a4c41cd2673e2bf30f4fd2

Contents?: true

Size: 568 Bytes

Versions: 10

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

require "rack"

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

      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 = settings.http_statuses_url
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.7.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.6.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.5.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.4.1 lib/pennyworth/loaders/http_status.rb
pennyworth-17.4.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.3.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.2.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.1.0 lib/pennyworth/loaders/http_status.rb
pennyworth-17.0.0 lib/pennyworth/loaders/http_status.rb