From: Josh Cheek Date: 2010-06-12T15:23:15+09:00 Subject: Re: How can I call foo in Bar.foo ? --0016e649c86646cc090488cf4ad4 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jun 12, 2010 at 12:33 AM, Ntys Dd wrote: > it's like this > ......................... > module Bar > def foo > puts 'hello' > end > def bye > puts 'bye' > end > end > > def Bar.foo > #Do something > #I want to call foo now > #And call bye > #... > end > ......................... > > is there anything i can to to solve the problem > -- > Posted via http://www.ruby-forum.com/. > > I won't advocate this as a solution, but it does seem to meet your criterion. module Bar def foo puts 'hello' end def bye puts 'bye' end end # Extends Bar's singleton class with its own instance methods p (class << Bar ; self ; end).ancestors Bar.extend Bar p (class << Bar ; self ; end).ancestors # since Bar is now an ancestor of itself, we can call super from within class methods def Bar.foo puts "doing something" super bye end Bar.foo --0016e649c86646cc090488cf4ad4--