Work around a weird Rails constant loading behaviour

What does this MR do?

Work around a weird Rails constant loading behaviour

This can be demonstrated as the following:

EE.const_get('API::Appearance', false) # => Appearance
EE.const_get('API::Appearance', false) # => raise NameError

Getting a NameError is what we're expecting here, because EE::API::Appearance doesn't exist.

Why this matters?

Why does this matter? EE::API::Appearance doesn't exist anyway, why do we want to attempt to load it?

This matters because in JH prepend_mod will attempt to load both EE module and JH module. For a class that an EE module exists, that doesn't mean a JH module will exist, therefore it'll attempt to load JH::API::Helpers::AwardEmoji but then it loads ::AwardEmoji!

In above specific case, API::Helpers::AwardEmoji should probably be renamed to API::Helpers::AwardEmojiHelper so it doesn't conflict with AwardEmoji, but this can really happen anywhere names can be conflicting.

References:

Edited by Lin Jen-Shin

Merge request reports

Loading