Created
October 7, 2014 16:57
-
-
Save hectorperez/4e08384c9ea22098039e to your computer and use it in GitHub Desktop.
check if a class already exists in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def class?(class_name) | |
| Kernel.const_defined?(class_name) && class_name.constantize.is_a?(Class) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment