This gem adds a
to_class method to
String that combines the functionality of ActiveSupport’s
constantize methods—it will convert the object in question to Camel case and then try to find a declared constant with the corresponding name. This allows you to easily get a class from its name with one simple method invocation.
Full documentation is at RubyDoc.info.
:user.to_class #=> User 'user'.to_class #=> User :blog_post.to_class #=> BlogPost 'blog_post'.to_class #=> BlogPost
If you like this gem, you may also want to check out Easier Instance Variable Access.
- ActiveSupport 3.0.5 — 20 May 2011
To send patches, please fork on GitHub and submit a pull request.
© 2011 Cody Robbins. See LICENSE for details.