We were getting a few errors when trying out Zeitwerk: ``` expected file lib/sms_api.rb to define constant SmsApi expected file app/components/layout/common_html_attributes_component.rb to define constant Layout::CommonHtmlAttributesComponent ``` In these cases, we aren't using an inflection because we also define the `Verification::SmsController` and a few migrations containing `Html` in their class name, and none of them would work if we defined the inflection. We were also getting an error regarding classes containing WYSIWYG in its name: ``` NameError: uninitialized constant WYSIWYGSanitizer Did you mean? WysiwygSanitizer ``` In this case, adding the acronym is easier, since we never use "Wysiwyg" in the code but we use "WYSIWYG" in many places.
22 lines
408 B
Ruby
22 lines
408 B
Ruby
class Layout::CommonHtmlAttributesComponent < ApplicationComponent
|
|
use_helpers :rtl?
|
|
|
|
private
|
|
|
|
def attributes
|
|
sanitize([dir, lang, html_class].compact.join(" "))
|
|
end
|
|
|
|
def dir
|
|
'dir="rtl"' if rtl?
|
|
end
|
|
|
|
def lang
|
|
"lang=\"#{I18n.locale}\""
|
|
end
|
|
|
|
def html_class
|
|
"class=\"tenant-#{Tenant.current_schema}\"" if Rails.application.config.multitenancy
|
|
end
|
|
end
|