The class is Componentdeclared in Package, so it seems to be correct. ::indicates to find a name Componentin an area Package_A. Since he is not there Component, he looks through the superclass.
This example shows how to achieve what you want. Perhaps there will be an easier way, I would be happy to see it.
class Package
class Component
def foo
puts "bar"
end
end
end
class Pack_a < Package
end
Pack_a::Component.new.foo
class Pack_b < Package
class Component
end
end
Pack_b::Component.new.foo
class Pack_c < Package
class Component < Package::Component
end
end
Pack_c::Component.new.foo
Pack_c::Component.new
This more or less should explain how the scope works in such cases. Hope this helps.
source
share