I have two files foo and bar. Foo implements class and initializes instance. Inside file bar.rb I want require foo.rb but also I want change implementation of Foo::Bar from foo.rb
dir tree
- foo.rb
- bar.rb
foo.rb
module Foo
class Bar
def random_method
puts "Foo::Bar.random_method"
end
end
end
Foo::Bar.new.random_method
bar.rb
#here I want overwrite Foo::Bar.random_method
require_relative 'foo' # so this line use new random_method
This is not possible (AFAIK), if you are not allowed to touch
foo.rb.A possible approach is to split declaration of
Foo::Barand the code that uses it.