ruby convert class name in string to actual class

后端 未结 6 1785
后悔当初
后悔当初 2020-12-12 20:03

How do I call a class from a string containing that class name inside of it? (I guess I could do case/when but that seems ugly.)

The reason I ask is because I\'m us

6条回答
  •  星月不相逢
    2020-12-12 20:41

    I think what you want is constantize

    That's an RoR construct. I don't know if there's one for ruby core

提交回复
热议问题