Closed catmando closed 8 years ago
@catmando Can't we raise a const missing exception if the method doesn't exist either, replicating as much standard ruby behavior as possible?
@ajjahn - if you mean in the case that you say Foo but there is no component Foo, then yes, I would say we just use call the original std lib method.
This is not going to work... what was I thinking Foo is defined as a constant so of course const_missing would never be raised.
This issue was moved to reactrb/reactrb#115
Currently you have to say Foo() or Foo {} so ruby can determine Foo is a method.
A recent SO question got me thinking about this http://stackoverflow.com/questions/34657494/why-does-a-method-call-need-to-be-disambiguated-when-it-can-in-principle-be-a-co/34659428#34659428
I see no reason why we should not update const_missing so that if the missing "const" is in fact a subclass of React::Component::Base (or has the mixin) then we go ahead and make the method call.
While it would require we open class Module, it would only effect the behavior of React Component classes, it would get rid of an exception that constantly confuses beginners, and make the code more readable.