Sha256: 7851e811b342c3d49b853f1bcc4cfc8a911402d9f4b7fe88de7eaf913995b441

Contents?: true

Size: 791 Bytes

Versions: 27

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module Helpers
    # Inflector provides inflection for the whole Karafka framework with additional inflection
    # caching (due to the fact, that Dry::Inflector is slow)
    module Inflector
      # What inflection engine do we want to use
      ENGINE = Dry::Inflector.new

      @map = Concurrent::Hash.new

      private_constant :ENGINE

      class << self
        # @param string [String] string that we want to convert to our underscore format
        # @return [String] inflected string
        # @example
        #   Karafka::Helpers::Inflector.map('Module/ControllerName') #=> 'module_controller_name'
        def map(string)
          @map[string] ||= ENGINE.underscore(string).tr('/', '_')
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
karafka-1.4.15 lib/karafka/helpers/inflector.rb
karafka-1.4.14 lib/karafka/helpers/inflector.rb
karafka-1.4.13 lib/karafka/helpers/inflector.rb
karafka-1.4.12 lib/karafka/helpers/inflector.rb
karafka-1.4.11 lib/karafka/helpers/inflector.rb
karafka-1.4.10 lib/karafka/helpers/inflector.rb
karafka-1.4.9 lib/karafka/helpers/inflector.rb
karafka-1.4.8 lib/karafka/helpers/inflector.rb
karafka-1.4.7 lib/karafka/helpers/inflector.rb
karafka-1.4.6 lib/karafka/helpers/inflector.rb
karafka-1.4.5 lib/karafka/helpers/inflector.rb
karafka-1.4.4 lib/karafka/helpers/inflector.rb
karafka-1.4.3 lib/karafka/helpers/inflector.rb
karafka-1.4.2 lib/karafka/helpers/inflector.rb
karafka-1.4.1 lib/karafka/helpers/inflector.rb
karafka-1.4.0 lib/karafka/helpers/inflector.rb
karafka-1.4.0.rc2 lib/karafka/helpers/inflector.rb
karafka-1.4.0.rc1 lib/karafka/helpers/inflector.rb
karafka-1.3.7 lib/karafka/helpers/inflector.rb
karafka-1.3.6 lib/karafka/helpers/inflector.rb