Sha256: 3b885c2e03540c3c975af5331cd450d02dc2943a91ce4c76858203bf9189dfbe

Contents?: true

Size: 684 Bytes

Versions: 9

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

require "rack"

module Pennyworth
  module Loaders
    # Loads an array of HTTP status records.
    class HTTPStatuses
      def initialize codes: Rack::Utils::HTTP_STATUS_CODES,
                     model: Models::HTTPStatus,
                     configuration: CLI::Configuration::Loader.call
        @codes = codes
        @model = model
        @configuration = configuration
      end

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

      private

      attr_reader :codes, :model, :configuration

      def url = configuration.http_statuses_url
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pennyworth-11.2.2 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.2.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.2.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.1.3 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.1.2 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.1.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.1.0 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.0.1 lib/pennyworth/loaders/http_statuses.rb
pennyworth-11.0.0 lib/pennyworth/loaders/http_statuses.rb