I have a simple class A declared as follows:

class A

def foo
  p "A::foo"
end

 def boo
   p "A::boo"
 end

end

Then I have a simple module ModuleA declared as follows:

module ModuleA
  def module_a_foo
     p 'ModuleA::module_a_foo'
  end

  def foo
     p 'ModuleA::foo'
   end
end

I declare an instance of class A as follows:

a1 = A.new
a1.methods.sort
I get all the methods that are declared in class A in my irb console

when I call a1.foo it prints the following as expected
"A::foo'

Now I reopen class A and include moduleA into this class as follows

class A
   include ModuleA
end

Now when I type a.methods.sort as expect it displays the methods from
ModuleA also

When I call 'a1.module_a_foo' it prints the following as expected.
"ModuleA::module_a_foo"

However now when I call a1.foo I am expecting it to print
"ModuleA::foo" instead I still get "A::foo".

I am expecting it to print ModuleA::foo because the method foo in
ModuleA would overwrite the method foo when I include ModuleA  after
reopening the class A later. Am I missing something here, can anyone
help me understand this.

Kiran Kumar