I am using Ruby on Rails 3.2.2 and I would like to know if it is possible to check whether a class or module is namespaced. That is, I would like to run something like the following
ANamespaceName::AnotherNamespaceName::AClassName.is_namespaced?
#=> true
ANamespaceName::AClassName.is_namespaced?
#=> true
AClassName.is_namespaced?
#=> false
In the above code the issue is related to stating / implementing the is_namespaced? method.
Working from “How do you find the namespace/module name programatically in Ruby on Rails?” you can use the presence of
::in the class name to test if there is an associated module.