I've got this rudimentary example
module TheirModule
class Klass
def self.do_something
KlassModule.klass_module_method()
end
module KlassModule
# Lots of other functionality
def self.klass_module_method
puts "Hello from TheirModule"
end
# Lots of other functionality
end
end
end
module MyModule
class Klass < TheirModule::Klass
module KlassModule
extend TheirModule::Klass::KlassModule
def self.klass_module_method
puts "Hello from MyModule"
end
end
end
end
Then calling this gives me unexpected results.
MyModule::Klass.do_something # Hello from TheirModule
My expectation is that MyModule::Klass
's KlassModule
will redefine the klass_module_method
originally defined in TheirModule::Klass
's KlassModule
like this...
MyModule::Klass.do_something # Hello from MyModule
this clearly isn't the case and I'm wondering...
- Why this doesn't work?
- What would be a ruby way to accomplish this?
EDIT: The one caveat is that I cannot edit the source of TheirModule