Teach Zeitwerk that REST is the class name, not Rest

Also add a comment about the inflector settings.

NameError: uninitialized constant InitialStateSerializer::REST
Did you mean?  Rest
/vagrant/app/serializers/initial_state_serializer.rb:7:in `<class:InitialStateSerializer>'
/vagrant/app/serializers/initial_state_serializer.rb:3:in `<main>'
This commit is contained in:
rubic0n 2021-01-31 17:20:02 -06:00
parent bee832d4ef
commit 497ec0c1db
1 changed files with 22 additions and 1 deletions

View File

@ -10,7 +10,27 @@
# inflect.uncountable %w( fish sheep )
# end
# : TODO : WTF IS THIS?
# When converting a file path to a constant name and vice versa, Rails uses inflections to know
# what to do. It uses the `humanize` method to convert a path to a constant, and it uses
# `underscore` to convert a constant to a path.
#
# The inflections below are ones that do not follow the typical convention of underscore/humanize.
# Referring to it as an "acronym" is the easiest way to tell it, "this constant should just be
# downcased to become a path".
#
# BEFORE:
# 'StatsD'.underscore
# => "stats_d"
# 'statsd'.humanize
# => "Statsd"
#
# AFTER: (inflect.acronym 'StatsD')
# 'StatsD'.underscore
# => "statsd"
# 'statsd'.humanize
# => "StatsD"
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'StatsD'
inflect.acronym 'OEmbed'
@ -19,4 +39,5 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'PubSubHubbub'
inflect.acronym 'ActivityStreams'
inflect.acronym 'JsonLd'
inflect.acronym 'REST'
end