I refactored a piece of the ActiveModel::Naming module. In the part of the code that tries to find the model_name for the passed argument, I changed the implementation from "type based" (checking for Class) to "behavior based" (checking for method)
This change behaves almost 100% the same as the previous implementation.
This gives a (very minor) speed boost if a class is passed, but more importantly; it allows an instance to define its "name".
We use one class to store most of our data. However, how this class should behave, depends on it's configuration. Routing, human names, partials all depend on this configuration. By allowing the instance to respond to model_name, we can easily take advantage of all ActiveModel based code.
Naming helpers should first check if passed object responds to model_…
Anything that removes is_a? is a 100% from me.
Alright, that was fast. Thx!