My program has following structure:
module M1
class A
def action
C.new.foo
end
end
class C
def foo
puts "M1::C foo"
end
end
end
module M2
class A
def action
C.new.foo
end
end
class C
def foo
puts "M2::C foo"
end
end
end
As both M1::A and M2::A share same code, I've been thinking of putting common code inside separate class (or module) and inherit from it (include it). Something like this:
class ABase
def action
C.new.foo
end
end
module M1
class A < ABase
end
class C
def foo
puts "M1::C foo"
end
end
end
module M2
class A < ABase
end
class C
def foo
puts "M2::C foo"
end
end
end
However, when I tried, I've got into trouble with name resolution uninitialized constant ABase::C. What is the proper way to achieve code sharing in this case?