Sha256: 3618ed11d249379f9a8f65b75399eda16db3fb91d6f080a25d8bf1222c560cef

Contents?: true

Size: 428 Bytes

Versions: 10

Compression:

Stored size: 428 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(Container[:settings].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

10 entries across 10 versions & 1 rubygems

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