class Alpha
  def self.const_missing(sym)
    "Alpha has no #{sym}"
  end
end

class Beta
  def self.const_missing(sym)
    "Beta has no #{sym}"
  end
end

class A < Alpha
end

class B < Beta
end

p Alpha::FOO       # "Alpha has no FOO"
p Beta::FOO        # "Beta has no FOO"
p A::FOO           # "Alpha has no FOO"
p B::FOO           # "Beta has no FOO"

