Class: Authentik::Api::Inflector

Inherits:
Zeitwerk::GemInflector
  • Object
show all
Defined in:
lib/authentik/api/inflector.rb

Constant Summary collapse

ACRONYMS =
%w[gdtc id ip ldap ldapapi mdm os pkce psso rac saml scim sms ssf tls totp uri url ws].map(&:capitalize).freeze
REGULAR_INFLECTIONS =
ACRONYMS.to_h { [ _1, _1.upcase ] }.freeze
IRREGULAR_INFLECTIONS =
{
  "OAuth2ProviderSetupUrls" => "OAuth2ProviderSetupURLs",
  "AuthenticatedSessionGeoIp" => "AuthenticatedSessionGeoIp",
  "AuthenticatedSessionUserAgentOs" => "AuthenticatedSessionUserAgentOs"
}.freeze
INFLECTIONS =
IRREGULAR_INFLECTIONS.merge(REGULAR_INFLECTIONS).freeze
INFLECTIONS_PATTERN =

Matches inflections followed by an upcase letter or EOL.

/(?:#{INFLECTIONS.keys.join("|")})(?=[A-Z]|\z)/.freeze

Instance Method Summary collapse

Instance Method Details

#camelize(basename, abspath) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/authentik/api/inflector.rb', line 22

def camelize(basename, abspath)
  if basename.end_with?("_api")
    super
  else
    super.gsub(INFLECTIONS_PATTERN, INFLECTIONS)
  end
end