How do you make class methods defined within a nested series of modules propagate up the module mixin tree?
Consider the following:
module A
def self.included(base)
base.extend(ClassMethods)
end
def foo; end
module ClassMethods
def bar; end
end
end
module B
include A
end
class C
include B
end
puts "B class methods: #{(B.methods-Module.methods).inspect}"
puts "B instance methods #{B.instance_methods.inspect}"
puts "C class methods: #{(C.methods-Class.methods).inspect}"
puts "C instance methods #{(C.instance_methods-Class.instance_methods).inspect}"
Class C does not inherit the class methods defined in A, even though it includes B.
B class methods: [:bar]
B instance methods [:foo]
C class methods: []
C instance methods [:foo]
Is there a neat way of ensuring the the class methods from A are propagated upwards into C (so I could call C.bar)? I'm looking for a nice generic method that doesn't involve specifically calling out and extending C with every inherited module.
Kind regards
Steve