Sha256: b5cac0fa2e84f18ba76e49ae8bf47fee9abffd66b51ddc5712a2c95a65b230eb

Contents?: true

Size: 439 Bytes

Versions: 8

Compression:

Stored size: 439 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) { |fallback| fallback }

    private

    attr_reader :overrides
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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