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