mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 12:53:44 +08:00
35b1185a08
I introduced DemonBase because I had got some conflict between `demon/base.rb` and `jobs/base.rb`, however, to not rename base class, it is possible to use regex on absolute path in Zeitwerk custom inflector.
26 lines
865 B
Ruby
26 lines
865 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
|
|
CUSTOM_PATHS = {
|
|
'canonical_url' => 'CanonicalURL',
|
|
'clean_up_unmatched_ips' => 'CleanUpUnmatchedIPs',
|
|
'homepage_constraint' => 'HomePageConstraint',
|
|
'ip_addr' => 'IPAddr',
|
|
'onpdiff' => 'ONPDiff',
|
|
'onceoff' => 'Jobs',
|
|
'pop3_polling_enabled_setting_validator' => 'POP3PollingEnabledSettingValidator',
|
|
'postgresql_fallback_adapter' => 'PostgreSQLFallbackHandler',
|
|
'regular' => 'Jobs',
|
|
'scheduled' => 'Jobs',
|
|
'source_url' => 'SourceURL',
|
|
'topic_query_sql' => 'TopicQuerySQL',
|
|
'version' => 'Discourse',
|
|
}
|
|
|
|
def self.camelize(basename, abspath)
|
|
return basename.camelize if abspath =~ /onceoff\.rb$/
|
|
return 'Jobs' if abspath =~ /jobs\/base\.rb$/
|
|
CUSTOM_PATHS.fetch(basename, basename.camelize)
|
|
end
|
|
end
|