Files
gitlab-foss/lib/gitlab/utils/class_name_converter.rb
2025-07-15 09:07:59 +00:00

22 lines
464 B
Ruby

# frozen_string_literal: true
module Gitlab
module Utils
# Converts a class into the string representation of its name
# Example: `ClassNameConverter.new(Ci::SecureFile).string_representation` returns "ci_secure_file"
class ClassNameConverter
def initialize(klass)
@klass = klass
end
def string_representation
klass.name.underscore.tr('/', '_')
end
private
attr_reader :klass
end
end
end