The following example fails
class A
class B
end
end
p Object.const_get 'A' # => A
p Object.const_get 'A::B' # => NameError: wrong constant name A::B
UPDATE
Questions about the topic asked earlier:
The last one gives a nice solution which can be evolved into
class String
def to_class
self.split('::').inject(Object) do |mod, class_name|
mod.const_get(class_name)
end
end
end
class A
class B
end
end
p "A::B".to_class # => A::B