Class: Karafka::Web::Inflector

Inherits:
Zeitwerk::GemInflector
  • Object
show all
Defined in:
lib/karafka/web/inflector.rb

Overview

Web UI Zeitwerk Inflector that allows us to have time prefixed files with migrations, similar to how Rails does that.

Instance Method Summary collapse

Instance Method Details

#camelize(basename, abspath) ⇒ String

Returns Constant name to be used for given file.

Parameters:

  • basename (String)

    of the file to be loaded

  • abspath (String)

    absolute path of the file to be loaded

Returns:

  • (String)

    Constant name to be used for given file



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/karafka/web/inflector.rb', line 19

def camelize(basename, abspath)
  # If not migration directory with proper migration files, use defaults
  return super unless abspath.match?(MIGRATION_ABSPATH_REGEXP)
  # If base name is not of a proper name in migrations, use defaults
  return super unless basename.match?(MIGRATION_BASENAME_REGEXP)

  super(
    # Extract only the name without the timestamp
    basename.match(MIGRATION_BASENAME_REGEXP).to_a.last,
    abspath
  )
end