Sha256: e67f1fb36eb1581e9ae670f3be3a5ffcb6ece4820848773e39c673e10adbb4e2

Contents?: true

Size: 445 Bytes

Versions: 1

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

module Pennyworth
  # Overrides any string to desired form if matched, otherwise answers the original string.
  class Inflector
    DEFAULTS = Array(CLI::Configuration::Loader.call.inflections).reduce({}, :merge)

    def initialize overrides = DEFAULTS
      @overrides = overrides
    end

    def call(key) = overrides.fetch(key) { |missing_key| missing_key }

    private

    attr_reader :overrides
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pennyworth-11.0.0 lib/pennyworth/inflector.rb