Open Skipants opened 4 years ago
Do you think this is specific to Rails? I can transfer it to the Ruby Style Guide issue tracker for you.
I'm not too sure. constantize
is a ActiveSupport method and I think my decision to put it here was based on making a rule around the usage of that method somehow. What's your thoughts on it, @pirj ?
I mean constantize
is definitely a Rails-related method, but is it about constantize or instrumenting class names?
> self.class.const_get("Obj" + "ect")
=> Object
Makes sense. Transfer away!
PR welcome! :-)
The problem:
As a developer, if I am changing how a class is used or named, I would need to grep against the codebase with the name of the class. If this class is ever referenced via
constantize
then I will not find that reference without already knowing it's already there.eg.
The solution: I think using
constantize
is the issue here. I think there are cases where it needs to be used, but in general it causes the problem I outlined.