you CAN teach an old dog ... wrote:
> Can module2 include module2 and add features to a class from module1?
> I tried:
> 
> module M1
>   class A; def f; "f"; end; end
>   class B; def f; "f"; end; end
> end
> 
> module M2
>   include M1
>   class A; def g; "g"; end; end  #don't want to subclass
> end
> 
> M2::A.new.g   # "g", as expected
> M2::A.new.f   # undefined method
> 
> M2::B::new.f  # "f" as expected
> 
> So defining class A in M2 does not 're-open" the included class, but
> creates a new class. M1::B, however, comes through fine in M2.
> 
> Is it possible 
> (1) for module M2 to locally modify the definition of M1::A ?
> (2) for this modified class to be accessible as M2::A ?

Yes, if you cheat a little:

module M2
   include M1
   M1::A.instance_eval do define_method :g do "G"; end end
end

p M2::A.new.g   # "G"
p M2::A.new.f   # "f"
p M2::B::new.f  # "f"
p M2::A         # M1::A