Sha256: 67e65f5e79b60f44dfd8fd28267e5a96fa7e2416acee83f9d81ef6f249b640c5

Contents?: true

Size: 434 Bytes

Versions: 24

Compression:

Stored size: 434 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(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

24 entries across 24 versions & 1 rubygems

Version Path
pennyworth-14.3.0 lib/pennyworth/inflector.rb
pennyworth-14.2.1 lib/pennyworth/inflector.rb
pennyworth-14.2.0 lib/pennyworth/inflector.rb
pennyworth-14.1.2 lib/pennyworth/inflector.rb
pennyworth-14.1.1 lib/pennyworth/inflector.rb
pennyworth-14.1.0 lib/pennyworth/inflector.rb
pennyworth-14.0.0 lib/pennyworth/inflector.rb
pennyworth-13.8.0 lib/pennyworth/inflector.rb
pennyworth-13.7.0 lib/pennyworth/inflector.rb
pennyworth-13.6.0 lib/pennyworth/inflector.rb
pennyworth-13.5.0 lib/pennyworth/inflector.rb
pennyworth-13.4.0 lib/pennyworth/inflector.rb
pennyworth-13.3.0 lib/pennyworth/inflector.rb
pennyworth-13.2.0 lib/pennyworth/inflector.rb
pennyworth-13.1.0 lib/pennyworth/inflector.rb
pennyworth-13.0.1 lib/pennyworth/inflector.rb
pennyworth-13.0.0 lib/pennyworth/inflector.rb
pennyworth-12.3.1 lib/pennyworth/inflector.rb
pennyworth-12.3.0 lib/pennyworth/inflector.rb
pennyworth-12.2.0 lib/pennyworth/inflector.rb